Ping Host from Ansible Server

Hello All - I am trying to do a ping test of all the hosts in /etc/ansible/hosts, from the Ansible server.

So the requirement is, the ansible server should do a ping test to all the host and return the output.

regards,Kumar

I would say https://fping.org/ is the tool you want for this.

Antony.

Thank you for sharing and letting me know about this.

But for learning purpose i am trying to write a Ansible script, how to achieve this requirement in Ansbile script

All my hosts are Cisco Routers and Switchees

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ping_module.html

for network appliances use
https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/net_ping_module.html
instead

For windows and linux, i have created a playbook to run everyday at 1am to check whether the host is reachable or not and data will be written to jinja template with html format for the final report.

Thanks again. But i am looking for a solution to Ping all the hosts defined in /etc/ansible/host file, from the Ansible server itself. Ansible Server where i am running the script should do a ping test to all the host i defined in the Inventory file.

will delegate_to: localhost work. I didnt try yet

https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/net_ping_module.html shows the tests reachability using ping from network device to a remote destination, which i am not looking for.

this should work
ansible all -m ping

No, since targets are appliances, they won't have python, the 'ping'
module checks that a) remote is reachable with connection settings
give b) ansible has python + json which are min requirements for
executing anything above raw and script.