每次我启动剧本时都会出现错误。我发现这是ios_config模块甚至是Python的问题。
我从radius那里得到了信息,该用户名已通过身份验证,这似乎可行。
我只希望在第一步中进行简单的配置更改。
Playbook.yaml
---
- name: Basic Show Commands
hosts: SWITCH
gather_facts: False
connection: local
tasks:
- name: add vlan
ios_config:
lines:
- vlan 3219
Ansible.cfg
:
[defaults]
transport = local
hostfile = ./hosts
host_key_checking = False
timeout = 5
运行命令:
sudo ansible-playbook -u A-USERNAME-N -k play.yaml -c paramiko (Username is written like this)
错误看起来像这样:
ansible-playbook 2.5.1
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/admin1/.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-playbook
python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it can also be a list of hosts, a directory or a list of paths , use [defaults]
inventory=/path/to/file|dir instead. This feature will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
SSH password:
Parsed /etc/ansible/hosts inventory source with ini plugin
PLAYBOOK: play.yaml ***********************************************************************************************************************************************************
1 plays in play.yaml
PLAY [Basic Show Commands] ****************************************************************************************************************************************************
META: ran handlers
TASK [add vlan] ***************************************************************************************************************************************************************
task path: /etc/ansible/play.yaml:25
<10.1.103.60> using connection plugin network_cli (was local)
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/network/ios/ios_config.py
<10.1.103.60> ESTABLISH LOCAL CONNECTION FOR USER: root
<10.1.103.60> EXEC /bin/sh -c 'echo ~ && sleep 0'
<10.1.103.60> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin1/.ansible/tmp/ansible-tmp-1553866282.25-60687928596971 `" && echo ansible-tmp-1553866282.25-60687928596971="` echo /home/admin1/.ansible/tmp/ansible-tmp-1553866282.25-60687928596971 `" ) && sleep 0'
<10.1.103.60> PUT /home/admin1/.ansible/tmp/ansible-local-21017N44pTj/tmpWR4cIJ TO /home/admin1/.ansible/tmp/ansible-tmp-1553866282.25-60687928596971/ios_config.py
<10.1.103.60> EXEC /bin/sh -c 'chmod u+x /home/admin1/.ansible/tmp/ansible-tmp-1553866282.25-60687928596971/ /home/admin1/.ansible/tmp/ansible-tmp-1553866282.25-60687928596971/ios_config.py && sleep 0'
<10.1.103.60> EXEC /bin/sh -c '/usr/bin/python /home/admin1/.ansible/tmp/ansible-tmp-1553866282.25-60687928596971/ios_config.py && sleep 0'
<10.1.103.60> EXEC /bin/sh -c 'rm -f -r /home/admin1/.ansible/tmp/ansible-tmp-1553866282.25-60687928596971/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_d8od9psi/ansible_modlib.zip/ansible/module_utils/network/ios/ios.py", line 114, in get_config
KeyError: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/ansible_d8od9psi/ansible_module_ios_config.py", line 573, in <module>
main()
File "/tmp/ansible_d8od9psi/ansible_module_ios_config.py", line 476, in main
config, have_banners = get_running_config(module, config)
File "/tmp/ansible_d8od9psi/ansible_module_ios_config.py", line 374, in get_running_config
contents = get_config(module, flags=flags)
File "/tmp/ansible_d8od9psi/ansible_modlib.zip/ansible/module_utils/network/ios/ios.py", line 117, in get_config
File "/tmp/ansible_d8od9psi/ansible_modlib.zip/ansible/module_utils/connection.py", line 149, in __rpc__
ansible.module_utils.connection.ConnectionError: show running-config all
^
% Invalid input detected at '^' marker.
DE003SW01#
fatal: [10.1.103.60]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_d8od9psi/ansible_modlib.zip/ansible/module_utils/network/ios/ios.py\", line 114, in get_config\nKeyError: ''\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/tmp/ansible_d8od9psi/ansible_module_ios_config.py\", line 573, in <module>\n main()\n File \"/tmp/ansible_d8od9psi/ansible_module_ios_config.py\", line 476, in main\n config, have_banners = get_running_config(module, config)\n File \"/tmp/ansible_d8od9psi/ansible_module_ios_config.py\", line 374, in get_running_config\n contents = get_config(module, flags=flags)\n File \"/tmp/ansible_d8od9psi/ansible_modlib.zip/ansible/module_utils/network/ios/ios.py\", line 117, in get_config\n File \"/tmp/ansible_d8od9psi/ansible_modlib.zip/ansible/module_utils/connection.py\", line 149, in __rpc__\nansible.module_utils.connection.ConnectionError: show running-config all\r\n ^\r\n% Invalid input detected at '^' marker.\r\n\r\nDE003SW01#\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}