ios_command does not seem to be working

110 views
Skip to first unread message

Mohamed Lrhazi

unread,
Jan 18, 2017, 4:39:50 PM1/18/17
to Ansible Project
Hello,

am trying ansible and ios_command module for the first time... it seems as if ansible is trying to execute normal unix commands instead of ios... what am I missing?


➜  cisco cat pb.yaml
---
- hosts: ios
  gather_facts: no
  connection: local

  tasks:
    - name: RUN 'SHOW VERSION'
      register: version
      ios_command:
        commands: "show version"

    - debug: var=version.stdout_lines
➜  cisco


Output:
➜  cisco ansible-playbook -i hosts -vvv pb.yaml
Using /etc/ansible/ansible.cfg as config file

PLAYBOOK: pb.yaml **************************************************************
1 plays in pb.yaml

PLAY [ios] *********************************************************************

TASK [RUN 'SHOW VERSION'] ******************************************************
task path: /home/admin/cisco/pb.yaml:7
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/network/ios/ios_command.py
<192.168.40.5> ESTABLISH SSH CONNECTION FOR USER: cisuser
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/network/ios/ios_command.py
<192.168.40.3> ESTABLISH SSH CONNECTION FOR USER: cisuser
<192.168.40.3> SSH: EXEC sshpass -d15 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o User=cisuser -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.40.3 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1484773198.47-54177158686784 `" && echo ansible-tmp-1484773198.47-54177158686784="` echo $HOME/.ansible/tmp/ansible-tmp-1484773198.47-54177158686784 `" ) && sleep 0'"'"''
<192.168.40.5> SSH: EXEC sshpass -d14 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o User=cisuser -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.40.5 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1484773198.47-114173880435726 `" && echo ansible-tmp-1484773198.47-114173880435726="` echo $HOME/.ansible/tmp/ansible-tmp-1484773198.47-114173880435726 `" ) && sleep 0'"'"''
<192.168.40.3> PUT /tmp/tmpmaV5qI TO % Invalid input detected at '^' marker./ios_command.py
<192.168.40.5> PUT /tmp/tmpGdwMLJ TO Line has invalid autocommand "/bin/sh -c ( umask 77 && mkdir -p ""/ios_command.py
<192.168.40.3> SSH: EXEC sshpass -d15 scp -C -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o User=cisuser -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/ansible-ssh-%h-%p-%r /tmp/tmpmaV5qI '[192.168.40.3]:'"'"'% Invalid input detected at '"'"'"'"'"'"'"'"'^'"'"'"'"'"'"'"'"' marker./ios_command.py'"'"''
<192.168.40.5> SSH: EXEC sshpass -d14 scp -C -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o User=cisuser -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/ansible-ssh-%h-%p-%r /tmp/tmpGdwMLJ '[192.168.40.5]:'"'"'Line has invalid autocommand "/bin/sh -c ( umask 77 && mkdir -p ""/ios_command.py'"'"''
fatal: [aquinas-2960-40.5]: FAILED! => {
    "failed": true,
    "msg": "failed to transfer file to Line has invalid autocommand \"/bin/sh -c ( umask 77 && mkdir -p \"\"/ios_command.py:\n\nAdministratively disabled.\n"
}
fatal: [aquinas-3750-40.3]: FAILED! => {
    "failed": true,
    "msg": "failed to transfer file to % Invalid input detected at '^' marker./ios_command.py:\n\nAdministratively disabled.\n"
}
        to retry, use: --limit @/home/admin/cisco/pb.retry

PLAY RECAP *********************************************************************
aquinas-2960-40.5          : ok=0    changed=0    unreachable=0    failed=1
aquinas-3750-40.3          : ok=0    changed=0    unreachable=0    failed=1

➜  


Thanks a lot,
Mohamed.

Peter Sprygada

unread,
Jan 18, 2017, 6:23:30 PM1/18/17
to ansible...@googlegroups.com
What version of Ansible are you running?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/351298d4-67e8-4b44-89a1-93c194bb7912%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages