Ping Host from Ansible Server

156 views
Skip to first unread message

R.B. Kumar

unread,
Jun 16, 2021, 11:21:33 AM6/16/21
to Ansible Project
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

Antony Stone

unread,
Jun 16, 2021, 11:27:10 AM6/16/21
to ansible...@googlegroups.com
I would say https://fping.org/ is the tool you want for this.

Antony.

--
Python is executable pseudocode.
Perl is executable line noise.

Please reply to the list;
please *don't* CC me.

R.B. Kumar

unread,
Jun 16, 2021, 11:36:43 AM6/16/21
to Ansible Project
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

Dick Visser

unread,
Jun 16, 2021, 11:47:47 AM6/16/21
to ansible...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c3e4a65c-e6d9-44d6-aa8d-637f5069b96en%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Brian Coca

unread,
Jun 16, 2021, 11:53:39 AM6/16/21
to Ansible Project
for network appliances use
https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/net_ping_module.html
instead


--
----------
Brian Coca

Thanh Nguyen Duc

unread,
Jun 16, 2021, 9:18:31 PM6/16/21
to ansible...@googlegroups.com
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.

Sent from my iPhone

> On 16 Jun 2021, at 23:53, Brian Coca <bc...@redhat.com> wrote:
>
> for network appliances use
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7eZd5MqM-MpZvHpcOv7Ao5EeYR61N-1VftoScHir7hanw%40mail.gmail.com.

R.B. Kumar

unread,
Jun 17, 2021, 2:52:31 AM6/17/21
to Ansible Project
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.

Rodrigues -

unread,
Jun 17, 2021, 2:49:45 PM6/17/21
to Ansible Project
this should work
ansible all -m ping 

Brian Coca

unread,
Jun 17, 2021, 3:53:52 PM6/17/21
to Ansible Project
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.

On Thu, Jun 17, 2021 at 2:49 PM Rodrigues - <bugp...@gmail.com> wrote:
>
> this should work
> ansible all -m ping
>


--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages