Very first time Network Engineer user - ping module needs to connect with SSH to work?

Hi All,

First time getting into any kind of automation -starting with Ansible.

Odd results for me. What is going on?

Thanks,
Greg

05:41root@xfrr3 /etc/ansible ? ansible f1 --module-name=ping172.16.0.1 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to connect to the host via ssh: Permission denied (publickey,password).\r
\n”,
“unreachable”: true
}
05:41root@xfrr3 /etc/ansible ? ping 172.16.0.1
PING 172.16.0.1 (172.16.0.1) 56(84) bytes of data.
64 bytes from 172.16.0.1: icmp_seq=1 ttl=255 time=0.410 ms
64 bytes from 172.16.0.1: icmp_seq=2 ttl=255 time=0.508 ms
^C
— 172.16.0.1 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1009ms
rtt min/avg/max/mdev = 0.410/0.459/0.508/0.049 ms
05:41root@xfrr3 /etc/ansible ?

does the other end have your public keys for the user you are running ansible? or the ssh keys loaded??

The ping module is not the classical ping command but an Ansible module that will connetc to the remote host via SSH and send back
a "pong" if that succeeds. See the docs.

If you want to use the classical ping command you need to use the "command" or "shell" module to call that from Ansible; but
beware that this task needs to be run on localhost to reflect what you would usually do on the command line.

If you check the documentation[1] it clearly state the following.

   ping - Try to connect to host, verify a usable python and return pong on success
     - This is NOT ICMP ping, this is just a trivial test module that requires Python on the remote-node.

oh ignore my comment I missed the networking part.

Hi,
Welcome to the Ansible Community

We have some Ansible Network getting started documentation which maybe a good place to start https://docs.ansible.com/ansible/latest/network/

Kind regards,
gundalow