1

I am using Ansible 2.7.10 in VM Workstation 15 Pro in Ubuntu machine (18.04.2 ) and trying to connect Cisco Routers (3700 Software (C3725-ADVIPSERVICESK9-M), Version 12.4(23)) in GNS3.

Raw ssh is working from Ubuntu terminal but getting below error while trying to ping via ansible ping module.

root@ubuntu:/etc/ansible# ansible Routers -m ping -u cisco -k -vvv
ansible 2.7.10
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
SSH password: 
/etc/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
Parsed /etc/ansible/hosts inventory source with ini plugin
META: ran handlers
<192.168.74.10> ESTABLISH SSH CONNECTION FOR USER: cisco
<192.168.74.10> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=no -o StrictHostKeyChecking=no -o User=cisco -o ConnectTimeout=10 192.168.74.10 '/bin/sh -c '"'"'echo ~cisco && sleep 0'"'"''
<192.168.74.10> (0, '\r\nLine has invalid autocommand "/bin/sh -c \'echo ~cisco && sleep 0\'"', '')
<192.168.74.10> ESTABLISH SSH CONNECTION FOR USER: cisco
<192.168.74.10> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=no -o StrictHostKeyChecking=no -o User=cisco -o ConnectTimeout=10 192.168.74.10 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo Line has invalid autocommand "/bin/sh -c '"'"'"'"'"'"'"'"'echo ~cisco && sleep 0'"'"'"'"'"'"'"'"'"/.ansible/tmp/ansible-tmp-1557556461.94-275071590111448 `" && echo ansible-tmp-1557556461.94-275071590111448="` echo Line has invalid autocommand "/bin/sh -c '"'"'"'"'"'"'"'"'echo ~cisco && sleep 0'"'"'"'"'"'"'"'"'"/.ansible/tmp/ansible-tmp-1557556461.94-275071590111448 `" ) && sleep 0'"'"''
<192.168.74.10> (0, '\r\nLine has invalid autocommand "/bin/sh -c \'( umask 77 && mkdir -p "` echo Line has invalid autocommand "/bin/sh -c \'"\'"\'echo ~cisco && sleep 0\'"\'"\'"/.ansible/tmp/ansible-tmp-1557556461.94-275071590111448 `" && echo ansible-tmp-1557556461.94-275071590111448="` echo Line has invalid auto"', '')
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/system/ping.py
<192.168.74.10> PUT /root/.ansible/tmp/ansible-local-82605nzIYYL/tmpRi045V TO "` echo Line has invalid auto"/AnsiballZ_ping.py
<192.168.74.10> SSH: EXEC sshpass -d9 scp -C -o ControlMaster=no -o StrictHostKeyChecking=no -o User=cisco -o ConnectTimeout=10 /root/.ansible/tmp/ansible-local-82605nzIYYL/tmpRi045V '[192.168.74.10]:'"'"'"` echo Line has invalid auto"/AnsiballZ_ping.py'"'"''
192.168.74.10 | FAILED! => {
    "msg": "failed to transfer file to /root/.ansible/tmp/ansible-local-82605nzIYYL/tmpRi045V \"` echo Line has invalid auto\"/AnsiballZ_ping.py:\n\nAdministratively disabled.\n"
}

Please advise.

1 Answer 1

1

The ping module in ansible is not actually just pinging the host as you would do manually from your shell. From the doc link above:

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

Since your are targeting a network device, you are getting an error because ansible is trying to transfer some files to the device prior to executing them with python as it would do on a 'normal' host. In your case, the device filesystem is readonly or not writable at the expected path (which is not surprising), and ansible fires an error.

Have a look at the ios_ping and net_ping modules that might meet you needs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .