Hello I have written a script to ping all my inventory hosts. Some are behind VPN services so before I can ping them I set up a tunnel.
This works fine, however if the tunnel is set up but the ansible ping does not succeed the entire play just halts and none of the subsequent tasks get executed ( tunnel does not get closed / rest of tasks for host that are reachable do not get executed )
How can I make the play continue and just skip the host that was unreachable? I've looked at "meta clear_host_errors" but that's not it.
Here's my script
- hosts:
- liveservers-direct
- liveservers-special
- liveservers-keypair
- testservers-direct
- testservers-special
- testservers-keypair
- intern
gather_facts: no
strategy: debug
become: no
tasks:
- name: Ping some servers
ping:
- hosts:
- liveservers-vpn
- testservers-vpn
strategy: debug
gather_facts: no
become: no
serial: 1
vars_files:
- ../roles/vpn/vars/customers.yml
tasks:
- include: ../roles/vpn/tasks/connect.yml icao="{{hostvars[inventory_hostname]['icao']}}"
- ping:
- name:
meta: clear_host_errors
- include: ../roles/vpn/tasks/disconnect.yml icao="{{hostvars[inventory_hostname]['icao']}}"
fatal: [server.behind.vpn]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 10.xx.xx.xx port 22: Connection timed out\r\n", "unreachable": true}
above error happens on "ping" how do I make it skip the failure and just continue with the rest of the hosts? the play just stops now when it reaches the unreachable host, but a few more need to be checked
serial: 1
? – techrafwhen
to distinguish host (or really group) specific tasks. – Andrew H