# Ping module error for a juniper nos

**URL:** <https://forum.ansible.com/t/ping-module-error-for-a-juniper-nos/2332>\
**Category:** Get Help\
**Tags:** network, ansible-core\
**Created:** [November 13, 2023, 3:11pm UTC](https://forum.ansible.com/t/ping-module-error-for-a-juniper-nos/2332 "2023-11-13T15:11:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saran307](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/saran307/32/176_2.png) [@Saran307](https://forum.ansible.com/u/Saran307)\
**Post date:** [November 13, 2023, 3:11pm UTC](https://forum.ansible.com/t/ping-module-error-for-a-juniper-nos/2332/1 "2023-11-13T15:11:55Z")

</div>

```auto
"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

```auto
[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.

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

```

I am using the below version

```auto
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 ?

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [November 13, 2023, 5:39pm UTC](https://forum.ansible.com/t/ping-module-error-for-a-juniper-nos/2332/2 "2023-11-13T17:39:03Z")

</div>

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](https://www.juniper.net/documentation/us/en/software/junos-ansible/ansible/topics/concept/junos-ansible-modules-overview.html#understanding-the-ansible-for-junos-os-collections-roles-and-modules__d51e156)

Use [junipernetworks.junos.junos\_ping module](https://docs.ansible.com/ansible/latest/collections/junipernetworks/junos/junos_ping_module.html#ansible-collections-junipernetworks-junos-junos-ping-module) or [ansible.netcommon.net\_ping module](https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/net_ping_module.html#ansible-collections-ansible-netcommon-net-ping-module) instead.

---

<div class="post-metadata">

**Author:** ![Saran307](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/saran307/32/176_2.png) [@Saran307](https://forum.ansible.com/u/Saran307)\
**Post date:** [November 14, 2023, 7:05am UTC](https://forum.ansible.com/t/ping-module-error-for-a-juniper-nos/2332/3 "2023-11-14T07:05:35Z")

</div>

Hi,

Thanks for keeping me posted.  
I tried to use the [junipernetworks.junos.junos\_ping](https://docs.ansible.com/ansible/latest/collections/junipernetworks/junos/junos_ping_module.html#ansible-collections-junipernetworks-junos-junos-ping-module) module but still I get the error

```auto
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.

---

<div class="post-metadata">

**Author:** ![jbericat](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jbericat/32/627_2.png) [@jbericat](https://forum.ansible.com/u/jbericat)\
**Post date:** [November 14, 2023, 3:56pm UTC](https://forum.ansible.com/t/ping-module-error-for-a-juniper-nos/2332/4 "2023-11-14T15:56:45Z")

</div>

Hello @Saran307,

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

> [@Not able to push playbook to Juniper Switch](http://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778/5):
>
> Two question/requests: Is netconf enabled on the Juniper device? You can use the junos\_netconf module to enable it: [junipernetworks.junos.junos\_netconf module – Configures the Junos Netconf system service — Ansible Documentation](https://docs.ansible.com/ansible/latest/collections/junipernetworks/junos/junos_netconf_module.html) You can see how I use it here: [https://github.com/ansible/workshops/blob/4c1bce058c55c435766a99dc5528b4fa1e1b1d3f/roles/configure\_routers/tasks/juniper\_default.yml#L19](https://github.com/ansible/workshops/blob/4c1bce058c55c435766a99dc5528b4fa1e1b1d3f/roles/configure_routers/tasks/juniper_default.yml#L19) Can you re-run your playbook with -vvvv (4 vs) so I can see what it is doing for the connection?

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [November 20, 2023, 5:22pm UTC](https://forum.ansible.com/t/ping-module-error-for-a-juniper-nos/2332/5 "2023-11-20T17:22:37Z")

</div>

> 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](https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/network_cli_connection.html), as stated in [documentation](https://docs.ansible.com/ansible/latest/collections/junipernetworks/junos/junos_ping_module.html#notes):

> This module works only with connection `network_cli`.
