Hi Ansible,
I am a newbie on Ansible, Last week when I was trying to use Ansible to send command to my router Cisco 3725 in GNS3 from my miniPC (CentOS 7 64 bits, Ansible version 2.5). It keeps failing with the following issue. 192.168.1.10 (my miniPC) 192.168.1.9 (my router)
########run playbook
`
[root@EY ansible]# ansible-playbook router.yml -vvvvvvvvvvv
ansible-playbook 2.5.0
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/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc
PLAYBOOK: router.yml ***********************************************************
1 plays in router.yml
PLAY [192.168.1.9] *************************************************************
META: ran handlers
TASK [run show version on remote devices] **************************************
task path: /etc/ansible/router.yml:7
<192.168.1.9> attempting to start connection
<192.168.1.9> using connection plugin network_cli
<192.168.1.9> local domain socket does not exist, starting it
<192.168.1.9> control socket path is /root/.ansible/pc/84f038c732
<192.168.1.9> <192.168.1.9> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 192.168.1.9
<192.168.1.9> <192.168.1.9> ssh connection done, setting terminal
<192.168.1.9> <192.168.1.9> loaded terminal plugin for network_os ios
<192.168.1.9> <192.168.1.9> loaded cliconf plugin for network_os ios
<192.168.1.9> <192.168.1.9> firing event: on_open_shell()
<192.168.1.9> <192.168.1.9> firing event: on_become
<192.168.1.9> <192.168.1.9> ssh connection has completed successfully
<192.168.1.9> connection to remote device started successfully
<192.168.1.9> local domain socket listeners started successfully
<192.168.1.9>
<192.168.1.9> local domain socket path is /root/.ansible/pc/84f038c732
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/common/parsing.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/six/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/basic.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/common/utils.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/common/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/ios/ios.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/ios/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/parsing/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/_text.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/pycompat24.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/connection.py
Using module file /usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_command.py
<192.168.1.9> ESTABLISH LOCAL CONNECTION FOR USER: root
<192.168.1.9> EXEC /bin/sh -c ‘echo ~ && sleep 0’
<192.168.1.9> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /root/.ansible/tmp/ansible-tmp-1524447089.65-260313024406209
” && echo ansible-tmp-1524447089.65-260313024406209=“echo /root/.ansible/tmp/ansible-tmp-1524447089.65-260313024406209
” ) && sleep 0’
<192.168.1.9> PUT /root/.ansible/tmp/ansible-local-2007vWdMIN/tmpmQErXi TO /root/.ansible/tmp/ansible-tmp-1524447089.65-260313024406209/ios_command.py
<192.168.1.9> EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1524447089.65-260313024406209/ /root/.ansible/tmp/ansible-tmp-1524447089.65-260313024406209/ios_command.py && sleep 0’
<192.168.1.9> EXEC /bin/sh -c ‘/usr/bin/python /root/.ansible/tmp/ansible-tmp-1524447089.65-260313024406209/ios_command.py && sleep 0’
<192.168.1.9> EXEC /bin/sh -c ‘rm -f -r /root/.ansible/tmp/ansible-tmp-1524447089.65-260313024406209/ > /dev/null 2>&1 && sleep 0’
ok: [192.168.1.9] => {
“changed”: false,
“invocation”: {
“module_args”: {
“auth_pass”: null,
“authorize”: null,
“commands”: [
“show version”
],
“host”: null,
“interval”: 1,
“match”: “all”,
“password”: null,
“port”: null,
“provider”: null,
“retries”: 10,
“ssh_keyfile”: null,
“timeout”: null,
“username”: null,
“wait_for”: null
}
},
“stdout”: [
“Cisco IOS Software, 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(25d), RELEASE SOFTWARE (fc1)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2010 by Cisco Systems, Inc.\nCompiled Wed 18-Aug-10 07:55 by prod_rel_team\n\nROM: ROMMON Emulation Microcode\nROM: 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(25d), RELEASE SOFTWARE (fc1)\n\nRTR uptime is 3 minutes\nSystem returned to ROM by unknown reload cause - suspect boot_data[BOOT_COUNT] 0x0, BOOT_COUNT 0, BOOTDATA 19\nSystem image file is "tftp://255.255.255.255/unknown"\n\n\nThis product contains cryptographic features and is subject to United\nStates and local country laws governing import, export, transfer and\nuse. Delivery of Cisco cryptographic products does not imply\nthird-party authority to import, export, distribute or use encryption.\nImporters, exporters, distributors and users are responsible for\ncompliance with U.S. and local country laws. By using this product you\nagree to comply with applicable laws and regulations. If you are unable\nto comply with U.S. and local laws, return this product immediately.\n\nA summary of U.S. laws governing Cisco cryptographic products may be found at:\nhttp://www.cisco.com/wwl/export/crypto/tool/stqrg.html\n\nIf you require further assistance please contact us by sending email to\nexport@cisco.com.\n\nCisco 3725 (R7000) processor (revision 0.1) with 124928K/6144K bytes of memory.\nProcessor board ID FTX0945W0MY\nR7000 CPU at 240MHz, Implementation 39, Rev 2.1, 256KB L2, 512KB L3 Cache\n4 FastEthernet interfaces\n6 Serial(sync/async) interfaces\nDRAM configuration is 64 bits wide with parity enabled.\n55K bytes of NVRAM.\n\nConfiguration register is 0x2102”
],
“stdout_lines”: [
[
“Cisco IOS Software, 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(25d), RELEASE SOFTWARE (fc1)”,
“Technical Support: http://www.cisco.com/techsupport”,
“Copyright (c) 1986-2010 by Cisco Systems, Inc.”,
“Compiled Wed 18-Aug-10 07:55 by prod_rel_team”,
“”,
“ROM: ROMMON Emulation Microcode”,
“ROM: 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(25d), RELEASE SOFTWARE (fc1)”,
“”,
“RTR uptime is 3 minutes”,
“System returned to ROM by unknown reload cause - suspect boot_data[BOOT_COUNT] 0x0, BOOT_COUNT 0, BOOTDATA 19”,
“System image file is "tftp://255.255.255.255/unknown"”,
“”,
“”,
“This product contains cryptographic features and is subject to United”,
“States and local country laws governing import, export, transfer and”,
“use. Delivery of Cisco cryptographic products does not imply”,
“third-party authority to import, export, distribute or use encryption.”,
“Importers, exporters, distributors and users are responsible for”,
“compliance with U.S. and local country laws. By using this product you”,
“agree to comply with applicable laws and regulations. If you are unable”,
“to comply with U.S. and local laws, return this product immediately.”,
“”,
“A summary of U.S. laws governing Cisco cryptographic products may be found at:”,
“http://www.cisco.com/wwl/export/crypto/tool/stqrg.html”,
“”,
“If you require further assistance please contact us by sending email to”,
“export@cisco.com.”,
“”,
“Cisco 3725 (R7000) processor (revision 0.1) with 124928K/6144K bytes of memory.”,
“Processor board ID FTX0945W0MY”,
“R7000 CPU at 240MHz, Implementation 39, Rev 2.1, 256KB L2, 512KB L3 Cache”,
“4 FastEthernet interfaces”,
“6 Serial(sync/async) interfaces”,
“DRAM configuration is 64 bits wide with parity enabled.”,
“55K bytes of NVRAM.”,
“”,
“Configuration register is 0x2102”
]
]
}
TASK [configure top level configuration] ***************************************
task path: /etc/ansible/router.yml:15
<192.168.1.9> attempting to start connection
<192.168.1.9> using connection plugin network_cli
<192.168.1.9> found existing local domain socket, using it!
<192.168.1.9> updating play_context for connection
<192.168.1.9>
<192.168.1.9> local domain socket path is /root/.ansible/pc/84f038c732
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/common/parsing.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/six/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/basic.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/common/config.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/common/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/ios/ios.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/ios/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/parsing/init.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/_text.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/pycompat24.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/network/common/utils.py
Using module_utils file /usr/lib/python2.7/site-packages/ansible/module_utils/connection.py
Using module file /usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_config.py
<192.168.1.9> ESTABLISH LOCAL CONNECTION FOR USER: root
<192.168.1.9> EXEC /bin/sh -c ‘echo ~ && sleep 0’
<192.168.1.9> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /root/.ansible/tmp/ansible-tmp-1524447090.34-174383710450736
” && echo ansible-tmp-1524447090.34-174383710450736=“echo /root/.ansible/tmp/ansible-tmp-1524447090.34-174383710450736
” ) && sleep 0’
<192.168.1.9> PUT /root/.ansible/tmp/ansible-local-2007vWdMIN/tmpgDDBMY TO /root/.ansible/tmp/ansible-tmp-1524447090.34-174383710450736/ios_config.py
<192.168.1.9> EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1524447090.34-174383710450736/ /root/.ansible/tmp/ansible-tmp-1524447090.34-174383710450736/ios_config.py && sleep 0’
<192.168.1.9> EXEC /bin/sh -c ‘/usr/bin/python /root/.ansible/tmp/ansible-tmp-1524447090.34-174383710450736/ios_config.py && sleep 0’
<192.168.1.9> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-152444709
The full traceback is:
Traceback (most recent call last):
File “/tmp/ansible_hfF8l5/ansible_module_ios_config.py”, line 572, in
main()
File “/tmp/ansible_hfF8l5/ansible_module_ios_config.py”, line 475, in main
config, have_banners = get_running_config(module, config)
File “/tmp/ansible_hfF8l5/ansible_module_ios_config.py”, line 373, in get_runn
contents = get_config(module, flags=flags)
File "/tmp/ansible_hfF8l5/ansible_modlib.zip/ansible/module_utils/network/ios/
File "/tmp/ansible_hfF8l5/ansible_modlib.zip/ansible/module_utils/connection.p
ansible.module_utils.connection.ConnectionError: show running-config all
^
% Invalid input detected at ‘^’ marker.
RTR#
fatal: [192.168.1.9]: FAILED! => {
“changed”: false,
“module_stderr”: "Traceback (most recent call last):\n File "/tmp/ansible_ansible_hfF8l5/ansible_module_ios_config.py", line 475, in main\n config, hadule_ios_config.py", line 373, in get_running_config\n contents = get_configils/network/ios/ios.py", line 117, in get_config\n File "/tmp/ansible_hfF8l5/odule_utils.connection.ConnectionError: show running-config all\r\n
“module_stdout”: “”,
“msg”: “MODULE FAILURE”,
“rc”: 1
}
to retry, use: --limit @/etc/ansible/router.retry
PLAY RECAP *********************************************************************
192.168.1.9 : ok=1 changed=0 unreachable=0 failed=1
`
###my ansible playbook
`