I am using the following playbook to check connectivity from target host 192.168.153.31 to 8.8.8.8
---
- hosts: 192.168.153.31
gather_facts: no
tasks:
- name: Ping net1
shell: |
ping -c3 8.8.8.8 >/dev/null
if [ $? -eq 0 ]
then
echo "ok"
else
echo "nok"
fi
ignore_errors: true
register: output
- name: end playbook
meta: end_host
when: output.stdout == 'nok'
based on output I have remaining tasks to be executed. Is there any better way to verify connectivity?