Typo in nxapi_lib.py
davidclin opened this issue · 1 comments
Description
The nxos_interface module fails when invoked.
Platform tested: Nexus 9396PX
NXOS image tested: 7.0(3)I1(2)
pycsco version: 0.3.1
Sample Playbook Used to Reproduce Problem
- name: sample playbook
hosts: n9k1
tasks:
- name: default interfaces
nxos_interface: interface={{ item }} state=default host={{ inventory_hostname }}
with_items:
- Ethernet1/1
- Ethernet2/1
- name: config interface
nxos_interface: interface=Ethernet1/1 description='Configured by Ansible' mode=layer3 host={{ inventory_hostname }}
- nxos_interface: interface=Ethernet2/1 admin_state=down host={{ inventory_hostname }}
Error Output
ubuntu@chef-server:~/nxos-ansible$ ansible-playbook -i hosts david.yml
PLAY [sample playbook] ********************************************************
TASK: [config interface] ******************************************************
failed: [N9K-Standalone-Pod-1] => {"failed": true, "parsed": false}
Traceback (most recent call last):
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1448398602.74-
16577284928682/nxos_interface", line 2002, in
main()
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1448398602.74-
16577284928682/nxos_interface", line 310, in main
existing = nxapi_lib.get_interface(device, e_interface)
File "/usr/local/lib/python2.7/dist-packages/pycsco/nxos/utils/nxapi_lib.py", line
493, in get_interface
elif inteface['mode'] == 'routed':
NameError: global name 'inteface' is not defined
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/ubuntu/david.retry
N9K-Standalone-Pod-1 : ok=0 changed=0 unreachable=0 failed=1
Resolution
Fix line 493 in nxapi_lib.py so 'inteface' (note typo) is replaced with 'interface':
...
if interface['mode'] == 'access' or interface['mode'] == 'trunk':
interface['mode'] = 'layer2'
elif interface['mode'] == 'routed':
interface['mode'] = 'layer3'
...
thanks and good catch!