Ansible.netcommon.net_ping module – Tests reachability using ping from a network device

Hello, 

I am trying to run a simple Ansible net_ping task, but for some reason it is not able to execute the command on switch:

It is probably something obvious I overlooked.

Though running the same command string in prompt mode directly on the switch, Cisco IOS XE, it is accepting it:

 
#ping ip 172.26.219.11 repeat 20 source 172.26.219.1
Type escape sequence to abort.
Sending 20, 100-byte ICMP Echos to 172.26.219.11, timeout is 2 seconds:
Packet sent with a source address of 172.26.219.1
!!!!!!!!!!!!!!!!!!!!

Ansible Runbook:

---

- name: Test network reachability

  hosts: iosxe  

  gather_facts: false

  tasks:

    - name: Ping the destination from the network device



      ansible.netcommon.net_ping:

       dest: 172.26.219.11

       source: 172.26.219.1

       count: 20

      register: ping_results


    - name: Display ping results

      debug:

        var: ping_results

 

debug:

run_commands

    return connection.run_commands(commands=commands, check_rc=check_rc)

  File "/usr/local/lib/python3.10/dist-packages/ansible/module_utils/connection.py", line 200, in __rpc__

    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)

fatal: [switch]: FAILED! => {

    "changed": false,

    "invocation": {

        "module_args": {

            "afi": "ip",

            "count": 20,

            "dest": "172.26.219.11",

            "df_bit": false,

            "egress": null,

            "ingress": null,

            "source": "172.26.219.1",

            "state": "present",

            "timeout": null,

            "vrf": null

        }

    },

    "msg": "ping ip 172.26.219.11 repeat 20 source 172.26.219.1\r\nTranslating \"ip\"...domain server (10.0.0.1)\r\n\r\nping ip 172.26.219.11 repeat 20 source 172.26.219.1\r\n                      ^\r\n% Invalid input detected at '^' marker.\r\n\r\nswitch>"

}


Thank you for your help.

Netmart