28 lines
1.3 KiB
YAML
28 lines
1.3 KiB
YAML
---
|
|
- name: Verify application HTTP endpoint
|
|
ansible.builtin.uri:
|
|
url: "{{ app_health_check_url }}"
|
|
method: GET
|
|
status_code: "{{ app_health_check_status_codes | default([200, 201, 202]) }}"
|
|
register: http_health_check
|
|
until: http_health_check.status in (app_health_check_status_codes | default([200, 201, 202]))
|
|
retries: "{{ app_health_check_retries | default(30) }}"
|
|
delay: "{{ app_health_check_delay | default(10) }}"
|
|
when: app_health_check | default(true) and app_health_check_method | default('docker') == 'http' and app_health_check_url is defined
|
|
|
|
- name: Wait for compose services to be running (and healthy if applicable)
|
|
ansible.builtin.command:
|
|
cmd: docker compose ps --all --format json
|
|
chdir: "{{ app_dir }}"
|
|
register: _compose_ps
|
|
changed_when: false
|
|
retries: "{{ app_health_check_retries | default(30) }}"
|
|
delay: "{{ app_health_check_delay | default(10) }}"
|
|
vars:
|
|
_services: "{{ _compose_ps.stdout_lines | map('from_json') | list }}"
|
|
until:
|
|
- _services | length > 0
|
|
- _services | rejectattr('State', 'equalto', 'running') | list | length == 0
|
|
- _services | selectattr('Health', 'defined') | selectattr('Health', 'in', ['unhealthy', 'starting']) | list | length == 0
|
|
when: app_health_check | default(true) and app_health_check_method | default('docker') == 'docker'
|