cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
628
Views
22
Helpful
3
Replies

Ansible- How to add a TAG to NXOS L3 Interface

JagadeeshKannaiah
Cisco Employee
Cisco Employee

Hello,

My host_vars file as follows.

--

loopbacks:
- { interface: loopback0, addr: 30.30.30.30, mask: 32, tag: 54321 }
- { interface: loopback1, addr: 10.200.200.22, mask: 32, tag: 54321 }

--

 

Tasks file as follows. 

name: CONFIGURE INTERFACE IP ADDR
nxos_l3_interface:
name: "{{ item.interface }}"
ipv4: "{{ item.addr }}/{{ item.mask }}"
tag: "{{ item.tag }}"

I get error as tag not recognisable 

 

 

3 Replies 3

qsnyder
Cisco Employee
Cisco Employee

I'm curious if, for whatever reason, the value is not being picked up as an integer.  Per the `nxos_l3_interface` docs, this must be an integer value -- but it may be being passed as a string.

You can debug the variable type using the commands referenced in this URL: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_filters.html#discovering-the-data-type

q.

qsnyder
Cisco Employee
Cisco Employee

For what its worth, I'm willing to bet this is actually the issue.
Based on this page: https://stackoverflow.com/questions/28234430/ansible-integer-variables-in-yaml

You may be able to do something like `"{{ item.tag | int }}"` to make sure that the integer filter is applied to the corresponding value supplied from the variable.

q.

JagadeeshKannaiah
Cisco Employee
Cisco Employee

Found out Ansible NXOS module I was using was not supporting many features. Solved the problem by upgrading Ansible NXOS module to 4.0.1. 

Thank you!