No host, but ping is done

Hi
I am new in ansible, and studing it on lab scheme.
I am confused one thing:
In inventory is host:

cis2 ansible_host=172.28.8.222

And then i try -m ping to it, recievd pong.

[WARNING]: ansible-pylibssh not installed, falling back to paramiko
cis2 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}

But, this host is absent.

— 172.28.8.222 ping statistics —
4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3059ms

ssh: connect to host 172.28.8.222 port 22: No route to host

What it is mean?

2 Likes

— 172.28.8.222 ping statistics —
4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3059ms

the host could have ICMP blocked, the “ping” module is not the same as ICMP ping. In the docs: ansible.builtin.ping module – Try to connect to host, verify a usable python and return pong on success — Ansible Documentation

This is NOT ICMP ping, this is just a trivial test module that requires Python on the remote-node.

However…

ssh: connect to host 172.28.8.222 port 22: No route to host

This is interesting… you should be able to ssh… even if ICMP is disabled… can you do a ansible-inventory --list, I am curious what it says

this

1 Like

I installed ansible for new Master server. Situation is the same.
Inventory:

- cis1 - host is active, configs right
- cis2 - host is active, configs wrong
- cis3 - host is absent

mks_ansible@debian-t1:~/ansible_configs$ ansible-inventory --list
{
    "_meta": {
        "hostvars": {
            "cis1": {
                "ansible_connection": "network_cli",
                "ansible_host": "172.28.8.221",
                "ansible_network_os": "ios",
                "ansible_user": "ansible",
                "ansible_password": "sss123"
            },
            "cis2": {
                "ansible_connection": "network_cli",
                "ansible_host": "172.28.8.222",
                "ansible_network_os": "ios",
                "ansible_user": "ansible",
                "ansible_password": "wrongpass"
            },
            "cis3": {
                "ansible_connection": "network_cli",
                "ansible_host": "172.28.8.223",
                "ansible_network_os": "ios",
                "ansible_user": "ansible",
                "ansible_password": "sss123"
            }
        }
    },
    "all": {
        "children": [
            "ungrouped",
            "routers_ios"
        ]
    },
    "routers_ios": {
        "hosts": [
            "cis1",
            "cis2",
            "cis3"
        ]
    }
}

Result:

mks_ansible@debian-t1:~/ansible_configs$ ansible routers_ios -m ping
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
cis1 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}
cis2 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}
cis3 | SUCCESS => {
“changed”: false,
“ping”: “pong”
}

This behavior only for routers (i tried with cisco and juniper). With linux and windows servers -m ping works correctly.

ansible.netcommon.net_ping should be used insted of ping module.

For Network targets, use the ansible.netcommon.net_ping module instead.
ansible.builtin.ping module – Try to connect to host, verify a usable python and return pong on success — Ansible Documentation

2 Likes

ansible.netcommon.net_ping should be used insted of ping module.

this ^, the ping module is verifying nothing for network devices, and not a valid test.

3 Likes

Hi @moiseev-ks! It looks like the post might be solved - could you check to see if the response by @kurokobo worked for you?

If so, it would be super helpful if you could click the :heavy_check_mark: on their post to accept the solution - it recognises the input of others, helps our volunteers find new issues to answer, and keeps the forum nice and tidy.

Thanks!
(this is template reply, do feel free to reply if I’ve misunderstood the situation!)

1 Like