Hi All
I am trying to run a playbook to configure vlan to and interface
configuration to the devices in gns3 hosts.
I am getting error while running the playbook.
Below yml plabook and error message.Please help to solve this problem
root@NetworkAutomation-1:~# nano Interfaceconfig.yml
root@NetworkAutomation-1:~# cat Interfaceconfig.yml
--- - name: Cisco Wired Campus Design
hosts: gns3-access
gather_facts: false
connection: local
vars:
cli:
username: root
password: cisco
tasks:
- name: Global config settings
ios_config:
provider: "{{ cli }}"
lines:
- vtp mode transparent
- spanning-tree mode rapid-pvst
- udld enable
- errdisable recovery cause all
- port-channel load-balance src-dst-ip
- ip name-server 8.8.8.8
- no ip http server
- ip http secure-server
- snmp-server community python1 RO
- snmp-server community python2 RW
- ntp server 87.81.181.2
- ntp update-calendar
- clock timezone PST -8
- clock summer-time PDT recurring
- service timestamps debug datetime msec localtime
- service timestamps log datetime msec localtime
- "vlan 1,10,20,30,40,50"
- ip default-gateway 192.168.122.1
- "ip dhcp snooping vlan 100,101"
- no ip dhcp snooping information option
- ip dhcp snooping
- "ip arp inspection vlan 100,101"
- spanning-tree portfast bpduguard default
register: print_output
- debug: var=print_output
- name: IPv6 nd policy
ios_config:
provider: "{{ cli }}"
parents: ipv6 nd raguard policy HOST_POLICY
lines:
- device-role host
register: print_output
- debug: var=print_output
- name: Interface settings
ios_config:
provider: "{{ cli }}"
parents: "interface {{ item.interface }}"
lines:
- "switchport access vlan {{ item.vlan }}"
- "switchport voice vlan {{ item.voice_vlan }}"
- switchport host
- switchport port-security maximum 2
- switchport port-security
- switchport port-security aging time 2
- switchport port-security aging type inactivity
- switchport port-security violation restrict
- ip arp inspection limit rate 100
- ip dhcp snooping limit rate 100
- ip verify source
- ipv6 nd raguard attach-policy HOST_POLICY
after:
- no shutdown
with_items:
- { interface : GigabitEthernet1/0, vlan : 100, voice_vlan : 101
}
- { interface : GigabitEthernet1/1, vlan : 10, voice_vlan : 101
}
- { interface : GigabitEthernet1/2, vlan : 20, voice_vlan : 101
}
- { interface : GigabitEthernet1/3, vlan : 30, voice_vlan : 101
}
register: print_output
- debug: var=print_output
root@NetworkAutomation-1:~# nano Interfaceconfig.yml
root@NetworkAutomation-1:~# nano Interfaceconfig.yml
root@NetworkAutomation-1:~# ansible-playbook Interfaceconfig.yml
[WARNING]: Could not match supplied host pattern, ignoring: hosts
PLAY [Cisco Wired Campus Design]
*********************************************************************************************
skipping: no hosts matched
PLAY RECAP
*******************************************************************************************************************
root@NetworkAutomation-1:~# nano Interfaceconfig.yml
root@NetworkAutomation-1:~# ansible -i hosts all --list-hosts
hosts (1):
IOU1
root@NetworkAutomation-1:~# nano Interfaceconfig.yml
root@NetworkAutomation-1:~# ansible -i hosts all --list-hosts
hosts (1):
IOU1
root@NetworkAutomation-1:~# ansible-playbook Interfaceconfig.yml
PLAY [Cisco Wired Campus Design]
*********************************************************************************************
TASK [Global config settings]
************************************************************************************************
An exception occurred during task execution. To see the full traceback, use
-vvv. The error was: IOU1(config)#
fatal: [IOU1]: FAILED! => {"changed": false, "module_stderr": "Traceback
(most recent call last):\n File
\"/root/.ansible/tmp/ansible-tmp-1561274202.1-24725137251892/AnsiballZ_ios_config.py\",
line 113, in <module>\n _ansiballz_main()\n File
\"/root/.ansible/tmp/ansible-tmp-1561274202.1-24725137251892/AnsiballZ_ios_config.py\",
line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path,
ANSIBALLZ_PARAMS)\n File
\"/root/.ansible/tmp/ansible-tmp-1561274202.1-24725137251892/AnsiballZ_ios_config.py\",
line 48, in invoke_module\n imp.load_module('__main__', mod, module,
MOD_DESC)\n File \"/tmp/ansible_ios_config_payload__Jz4nK/__main__.py\",
line 541, in <module>\n File
\"/tmp/ansible_ios_config_payload__Jz4nK/__main__.py\", line 472, in main\n
File \"/tmp/ansible_ios_config_payload__Jz4nK/__main__.py\", line 333, in
edit_config_or_macro\n File
\"/tmp/ansible_ios_config_payload__Jz4nK/ansible_ios_config_payload.zip/ansible/module_utils/connection.py\",
line 182, in __rpc__\nansible.module_utils.connection.ConnectionError: udld
enable\r\n ^\r\n% Invalid input detected at '^'
marker.\r\n\r\nIOU1(config)#\n", "module_stdout": "", "msg": "MODULE
FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
to retry, use: --limit @/root/Interfaceconfig.retry
PLAY RECAP
*******************************************************************************************************************
IOU1 : ok=0 changed=0 unreachable=0 failed=1
root@NetworkAutomation-1:~# ansible-playbook Interfaceconfig.yml -vvv
ansible-playbook 2.7.11
config file = /root/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-playbook
python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0
20160609]
Using /root/ansible.cfg as config file
/root/hosts did not meet host_list requirements, check plugin documentation
if this is unexpected
/root/hosts did not meet script requirements, check plugin documentation if
this is unexpected
Parsed /root/hosts inventory source with ini plugin
PLAYBOOK: Interfaceconfig.yml
************************************************************************************************
1 plays in Interfaceconfig.yml
PLAY [Cisco Wired Campus Design]
*********************************************************************************************
META: ran handlers
TASK [Global config settings]
************************************************************************************************
task path: /root/Interfaceconfig.yml:11
<IOU1> using connection plugin network_cli (was local)
<IOU1> ESTABLISH LOCAL CONNECTION FOR USER: root
<IOU1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<IOU1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702 `" && echo
ansible-tmp-1561274349.79-59337482346702="` echo
/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702 `" ) && sleep 0'
Using module file
/usr/lib/python2.7/dist-packages/ansible/modules/network/ios/ios_config.py
<IOU1> PUT /root/.ansible/tmp/ansible-local-20642gBJ_fc/tmpVTg46H TO
/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/AnsiballZ_ios_config.py
<IOU1> EXEC /bin/sh -c 'chmod u+x
/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/
/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/AnsiballZ_ios_config.py
&& sleep 0'
<IOU1> EXEC /bin/sh -c '/usr/bin/python
/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/AnsiballZ_ios_config.py
&& sleep 0'
<IOU1> EXEC /bin/sh -c 'rm -f -r
/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/ > /dev/null
2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File
"/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/AnsiballZ_ios_config.py",
line 113, in <module>
_ansiballz_main()
File
"/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/AnsiballZ_ios_config.py",
line 105, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File
"/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/AnsiballZ_ios_config.py",
line 48, in invoke_module
imp.load_module('__main__', mod, module, MOD_DESC)
File "/tmp/ansible_ios_config_payload_XsAY0f/__main__.py", line 541, in
<module>
File "/tmp/ansible_ios_config_payload_XsAY0f/__main__.py", line 472, in
main
File "/tmp/ansible_ios_config_payload_XsAY0f/__main__.py", line 333, in
edit_config_or_macro
File
"/tmp/ansible_ios_config_payload_XsAY0f/ansible_ios_config_payload.zip/ansible/module_utils/connection.py",
line 182, in __rpc__
ansible.module_utils.connection.ConnectionError: udld enable
^
% Invalid input detected at '^' marker.
IOU1(config)#
fatal: [IOU1]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File
\"/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/AnsiballZ_ios_config.py\",
line 113, in <module>\n _ansiballz_main()\n File
\"/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/AnsiballZ_ios_config.py\",
line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path,
ANSIBALLZ_PARAMS)\n File
\"/root/.ansible/tmp/ansible-tmp-1561274349.79-59337482346702/AnsiballZ_ios_config.py\",
line 48, in invoke_module\n imp.load_module('__main__', mod, module,
MOD_DESC)\n File \"/tmp/ansible_ios_config_payload_XsAY0f/__main__.py\",
line 541, in <module>\n File
\"/tmp/ansible_ios_config_payload_XsAY0f/__main__.py\", line 472, in main\n
File \"/tmp/ansible_ios_config_payload_XsAY0f/__main__.py\", line 333, in
edit_config_or_macro\n File
\"/tmp/ansible_ios_config_payload_XsAY0f/ansible_ios_config_payload.zip/ansible/module_utils/connection.py\",
line 182, in __rpc__\nansible.module_utils.connection.ConnectionError: udld
enable\r\n ^\r\n% Invalid input detected at '^'
marker.\r\n\r\nIOU1(config)#\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
to retry, use: --limit @/root/Interfaceconfig.retry
PLAY RECAP
*******************************************************************************************************************
IOU1 : ok=0 changed=0 unreachable=0 failed=1
root@NetworkAutomation-1:~# ansible-playbook Interfaceconfig.yml --limit
@/root/Interfaceconfig.retry
PLAY [Cisco Wired Campus Design]
*********************************************************************************************
TASK [Global config settings]
************************************************************************************************
An exception occurred during task execution. To see the full traceback, use
-vvv. The error was: IOU1(config)#
fatal: [IOU1]: FAILED! => {"changed": false, "module_stderr": "Traceback
(most recent call last):\n File
\"/root/.ansible/tmp/ansible-tmp-1561274433.43-217491990236606/AnsiballZ_ios_config.py\",
line 113, in <module>\n _ansiballz_main()\n File
\"/root/.ansible/tmp/ansible-tmp-1561274433.43-217491990236606/AnsiballZ_ios_config.py\",
line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path,
ANSIBALLZ_PARAMS)\n File
\"/root/.ansible/tmp/ansible-tmp-1561274433.43-217491990236606/AnsiballZ_ios_config.py\",
line 48, in invoke_module\n imp.load_module('__main__', mod, module,
MOD_DESC)\n File \"/tmp/ansible_ios_config_payload_5B5Yhd/__main__.py\",
line 541, in <module>\n File
\"/tmp/ansible_ios_config_payload_5B5Yhd/__main__.py\", line 472, in main\n
File \"/tmp/ansible_ios_config_payload_5B5Yhd/__main__.py\", line 333, in
edit_config_or_macro\n File
\"/tmp/ansible_ios_config_payload_5B5Yhd/ansible_ios_config_payload.zip/ansible/module_utils/connection.py\",
line 182, in __rpc__\nansible.module_utils.connection.ConnectionError: udld
enable\r\n ^\r\n% Invalid input detected at '^'
marker.\r\n\r\nIOU1(config)#\n", "module_stdout": "", "msg": "MODULE
FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
to retry, use: --limit @/root/Interfaceconfig.retry
PLAY RECAP
*******************************************************************************************************************
IOU1 : ok=0 changed=0 unreachable=0 failed=1
root@NetworkAutomation-1:~# ^C
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CANQHRf3EAk01q39MO3CkSUdYp48C1Vz-nEpsfgrFw9PkN7Y7Rw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.