# Ping Host from Ansible Server

**URL:** <https://forum.ansible.com/t/ping-host-from-ansible-server/35362>\
**Category:** Ansible Project\
**Created:** [June 16, 2021, 3:21pm UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362 "2021-06-16T15:21:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![R.B\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/d07c76/32.png) [@R.B\_Kumar](https://forum.ansible.com/u/R.B_Kumar)\
**Post date:** [June 16, 2021, 3:21pm UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362/1 "2021-06-16T15:21:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Antony\_Stone](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Antony\_Stone](https://forum.ansible.com/u/Antony_Stone)\
**Post date:** [June 16, 2021, 3:26pm UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362/2 "2021-06-16T15:26:52Z")

</div>

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

Antony.

---

<div class="post-metadata">

**Author:** ![R.B\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/d07c76/32.png) [@R.B\_Kumar](https://forum.ansible.com/u/R.B_Kumar)\
**Post date:** [June 16, 2021, 3:36pm UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362/3 "2021-06-16T15:36:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [June 16, 2021, 3:47pm UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362/4 "2021-06-16T15:47:23Z")

</div>

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ping\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ping_module.html)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 16, 2021, 3:52pm UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362/5 "2021-06-16T15:52:05Z")

</div>

for network appliances use  
[https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/net\_ping\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/net_ping_module.html)  
instead

---

<div class="post-metadata">

**Author:** ![Thanh\_Nguyen\_Duc](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@Thanh\_Nguyen\_Duc](https://forum.ansible.com/u/Thanh_Nguyen_Duc)\
**Post date:** [June 17, 2021, 1:18am UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362/6 "2021-06-17T01:18:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![R.B\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/d07c76/32.png) [@R.B\_Kumar](https://forum.ansible.com/u/R.B_Kumar)\
**Post date:** [June 17, 2021, 6:52am UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362/7 "2021-06-17T06:52:31Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Rodrigues](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@Rodrigues](https://forum.ansible.com/u/Rodrigues)\
**Post date:** [June 17, 2021, 6:49pm UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362/8 "2021-06-17T18:49:45Z")

</div>

this should work  
ansible all -m ping

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 17, 2021, 7:53pm UTC](https://forum.ansible.com/t/ping-host-from-ansible-server/35362/9 "2021-06-17T19:53:07Z")

</div>

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.
