I have the following and there may be several vlans per switch.
"cisco_ios.vlans": {
"35": {
"id": "35",
"mtu": "1500",
"name": "CC_internal_subnet_35",
"ports": [
"GigabitEthernet1/0/1",
"GigabitEthernet1/0/2",
"GigabitEthernet1/0/20"
],
"status": "active"
},
"499": {
"id": "499",
"mtu": "1500",
"name": "Lync_VoIP_Burnside1",
"ports": [
""
],
"status": "active"
}
}
I want to be able to reference the data in here. Example, I am looking to
loop through al *.ports. I'm trying to do the following which does not work
vars:
old_vlan: 35
new_vlan: 45
- name: Change vlan old_vlan to new_vlan for all ports in list
debug:
msg: "Old VLAN is {{ old_vlan }} and port {{ item }} needs to be
changed"
loop: '{{ cisco_ios.vlans["{{ old_vlan }}"].ports }}'
The following work: loop: '{{ cisco_ios.vlans["35"].ports }}'
but how do I substitute 35 with the variable old_vlan which contains 35?
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/cd37806b-f4ce-4313-9043-6a33b1d1f638%40googlegroups.com.