--- - name: Wait for container to be healthy community.docker.docker_container_info: name: "{{ app_container_name }}" register: container_info until: container_info.container.State.Health.Status | default('healthy') == 'healthy' 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') == 'docker' ignore_errors: true - 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 ignore_errors: true - name: Inspect compose project containers community.docker.docker_host_info: containers: true containers_all: true containers_filters: label: "com.docker.compose.project={{ app_compose_project_name }}" register: compose_containers when: app_health_check | default(true) - name: Verify deployment success vars: _total: "{{ compose_containers.containers | length }}" _running: "{{ compose_containers.containers | selectattr('State', 'equalto', 'running') | list | length }}" ansible.builtin.assert: that: - compose_containers.containers | length > 0 - _running == _total fail_msg: "Not all containers are running. Running: {{ _running }}, Total: {{ _total }}" success_msg: "All containers are running successfully." when: app_health_check | default(true) and compose_containers.containers is defined