Last active
January 22, 2020 10:35
-
-
Save gmaurice/2ed09e3275d19b95be476298945b1f33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible-playbook -v -i 127.0.0.1, --extra-vars "port=9999" playbook.yml | |
playbook.yml: | |
- hosts: 127.0.0.1 | |
connection: local | |
gather_facts: no | |
tasks: | |
- wait_for: | |
host: "{{ item }}" | |
port: "{{ port }}" | |
timeout: 5 | |
msg: "unable to connect" | |
state: started | |
delay: 5 | |
retries: 120 | |
ignore_errors: true | |
with_items: "{{ hostvars.keys()|list }}" | |
Output: | |
PLAY [127.0.0.1] ******************************************************************************************************************************************* | |
TASK [wait_for host={{ item }}, port={{ port }}, timeout=5, msg=unable to connect, state=started, delay=5] ************************************************* | |
[WARNING]: Platform darwin on host 127.0.0.1 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python | |
interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information. | |
failed: [127.0.0.1] (item=127.0.0.1) => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "ansible_loop_var": "item", "changed": false, "elapsed": 5, "item": "127.0.0.1", "msg": "unable to connect"} | |
...ignoring | |
=========================== | |
The problem i have is as soon as there is an error, it's stopping. There are no retries. | |
I tried to use "until" keyword, but i can't manage something consistent (i.e. the same json structure on output) | |
If someone could, i would be grateful. | |
Thank you | |
=========================== | |
Solution which works: | |
- hosts: 127.0.0.1 | |
connection: local | |
gather_facts: no | |
tasks: | |
- wait_for: | |
host: "{{ item }}" | |
port: "{{ port }}" | |
timeout: 120 | |
state: started | |
with_items: "{{ hostvars.keys()|list }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment