Skip to content

Instantly share code, notes, and snippets.

@ihard
Created February 24, 2018 21:31
Show Gist options
  • Save ihard/8a3be9e563b25f703d63e00d42427dc0 to your computer and use it in GitHub Desktop.
Save ihard/8a3be9e563b25f703d63e00d42427dc0 to your computer and use it in GitHub Desktop.
ansible-wait
- name: wait for open all app ports
# - debug:
# var: app_state_port_result
- name: wait for success ping
uri:
url: "{{ item.proto|d('http') }}://127.0.0.1:{{ item.port }}{{ item.location|d('/' + '/monitoring/ping') }}"
headers:
Host: "{{ item.host|d('127.0.0.1') }}"
return_content: yes
follow_redirects: none
status_code: 200
body_format: json
validate_certs: no
timeout: 1
register: app_state_ping_result
until: "'json' in app_state_ping_result and app_state_ping_result.json.status.code in [0,2]"
retries: 2
delay: 1
when: item.ssl is undefined
with_items: "{{ app_ports }}"
ignore_errors: yes
loop_control:
label: "{{ item.port }}"
# - debug:
# var: app_state_ping_result
#ignore_errors: "{{ app_state_ignore_errors }}"
#failed_when: "{{ app_state_ignore_errors }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment