Ansible 1.9.1 SSH Error from ping module to Junos

792 views
Skip to first unread message

Matt Mcpherson

unread,
May 28, 2015, 1:42:40 PM5/28/15
to ansible...@googlegroups.com
Good afternoon all, my apologies for posting but I have been stopped at this point with no result for a few days.  I have installed Ansible 1.9.1 and , I believe, all required dependencies on CentOS 7 , I am looking to use Ansible to manage Junos equpment and installed the Juniper.junos module along with its dependencies.  

When I try to connect to my hosts via ansible ping module I am having an SSH issue.  From my Ansible server I can directly SSH to the Junos devices that I want to manage using the public rsa key loaded into my Junos config for login "matt".  But when I run the ping module I am unable to complete the test.  Here is my output.... 

[root@localhost /]# ansible all -m ping -vvvv
<10.71.16.5> ESTABLISH CONNECTION FOR USER: matt
<10.71.16.5> REMOTE_MODULE ping
<10.71.16.5> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=matt -o ConnectTimeout=10 10.71.16.5 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1432831825.76-143908795390292 && echo $HOME/.ansible/tmp/ansible-tmp-1432831825.76-143908795390292'
<10.71.16.5> PUT /tmp/tmpp9HeF0 TO error: unknown command: /bin/sh/ping
<10.71.16.5> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=matt -o ConnectTimeout=10 10.71.16.5 /bin/sh -c 'LANG=C LC_CTYPE=C /usr/bin/python error: unknown command: /bin/sh/ping'
10.71.16.5 | FAILED >> {
    "failed": true,
    "msg": "\r\nerror: unknown command: /bin/sh\r\nOpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 56: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 2464\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 10.71.16.5 closed.\r\n",
    "parsed": false
}


I also tried ping as root to the Junos devices using the -u and -k options, again I can connect directly via SSH, but when I run "ping" or a playbook referencing "ping"  then enter the password I also cannot connect.  

Can someone help?  

Matt Mcpherson

unread,
May 28, 2015, 3:34:08 PM5/28/15
to ansible...@googlegroups.com
So, after continuing to look at this it appears that SSH / paramiko are working but the ping module is failing to load the python interpreter.  There are symbolic links already created from /usr/bin/python ---> /usr/bin/python2.7   .... I tried specifying the direct path to the hosts file 

10.71.16.2     ansible_python_interpreter=usr/bin/python2.7 

This produced the following error (at least referencing the new location for python interpreter) 

10.71.16.2 | FAILED >> {
    "failed": true,
    "msg": "/usr/bin/python2.7: not found\n",
    "parsed": false
}


Any help would be greatly appreciated.  

Brian Coca

unread,
May 28, 2015, 6:10:10 PM5/28/15
to ansible...@googlegroups.com
the ping module uses the python on the target machine (it is not a
network ping), do the junos switches have python on them?



--
Brian Coca

Prasanna Siriki

unread,
Jun 12, 2015, 1:24:05 PM6/12/15
to ansible...@googlegroups.com
Hi Matt,

in the /etc/ansible/hosts 
host1 ansible_connection=local ansible_ssh_host=10.71.16.5

hope this may help you

Regards,
siriki

Mark Reyes

unread,
Nov 16, 2017, 12:30:26 AM11/16/17
to Ansible Project
This got it for me!
Ansible threw out so many weird errors, once local connection was specified... they all went away. 
Reply all
Reply to author
Forward
0 new messages