What does ansible all -m ping actually test, and why is it not a network ping?
It logs in to each host and runs a tiny module that answers "ping": "pong". That proves SSH login works and a usable Python exists on the host. It sends no ICMP packet.
$ ansible all -m ping
servera.lab.example.com | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false,
"ping": "pong"
}
The name misleads. An ICMP ping (the ping shell command) only shows that a machine answers on the network. Ansible's ping module goes all the way through Ansible's own path: connect over SSH, authenticate, find a Python interpreter (shown as discovered_interpreter_python), copy and run a module, and return JSON. A SUCCESS therefore means "Ansible can manage this host", a much stronger statement. "changed": false shows it modified nothing.
It is meant for ad-hoc checks, not for playbooks. Windows hosts use win_ping and network devices net_ping instead, because they don't run Python.
Go deeper:
ping module (official docs) โ "This is NOT ICMP ping", plus the Windows and network variants.