Ping module error for a juniper nos

"module_stderr": "Shared connection to rch2-prod-vpn-1.net closed.\r\n",
"module_stdout": "\r\nerror: unknown command: /bin/sh\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0

-I added a host file in my inventory

[vSRX]
rch2-prod-vpn-1.net

I tried to ping the target device with the below command but it is resulting in error above mentioned error.

ansible vSRX -m ping -vv 
ansible rch2-prod-vpn-1.net -m ping

I am using the below version

ksaran@buildnet6200:/etc/ansible# ansible --version
ansible [core 2.13.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ksaran/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/ksaran/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.16 (main, Apr  1 2023, 04:44:33) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18.0.1)]
  jinja version = 3.1.2
  libyaml = True

Can someone help me with this ?

1 Like

Hi,

It’s apparently a common issue / misconception about running Ansible on JunOS. See: Understanding the Ansible for Junos OS Collections, Roles, and Modules | Ansible for Junos OS Developer Guide | Juniper Networks TechLibrary

Use junipernetworks.junos.junos_ping module or ansible.netcommon.net_ping module instead.

2 Likes

Hi,

Thanks for keeping me posted.
I tried to use the junipernetworks.junos.junos_ping module but still I get the error

ksaran@buildnet6200:~# ansible vSRX -m junipernetworks.junos.junos_ping
[WARNING]: sftp transfer mechanism failed on [rch2-prod-vpn-1.net]. Use ANSIBLE_DEBUG=1 to see detailed information
[WARNING]: sftp transfer mechanism failed on [10.221.52.41]. Use ANSIBLE_DEBUG=1 to see detailed information
[WARNING]: scp transfer mechanism failed on [rch2-prod-vpn-1.net]. Use ANSIBLE_DEBUG=1 to see detailed information
[WARNING]: scp transfer mechanism failed on [10.221.52.41]. Use ANSIBLE_DEBUG=1 to see detailed information
rch2-prod-vpn-1.net | FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to rch2-prod-vpn-1.net closed.\r\n",
    "module_stdout": "\r\nerror: unknown command: /bin/sh\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 0
}
10.221.52.41 | FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to 10.221.52.41 closed.\r\n",
    "module_stdout": "\r\nerror: unknown command: /bin/sh\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 0
}

My concern is why there is warning message showing SFTP while i am trying to do Ping and i created a play and try to execute it but it still throws the same error.

Hello @Saran307,

I don’t have much experience with juniper but I’ve read something around here about similar problems. Check this out:

1 Like

My concern is why there is warning message showing SFTP while i am trying to do Ping

Probably because Ansible is trying to copy the module over, as it’s not an ICMP ping but a script executing locally.

In addition to @jbericat answer, also ensure you are using network_cli connection plugin, as stated in documentation:

This module works only with connection network_cli.

1 Like