I would like to access data in a dictionary by referencing a variable. I have the following dict:
`
“vlan_list”: {
“1”: {
“id”: “1”,
“name”: “Management”,
“status”: “active”
},
“2”: {
“id”: “2”,
“name”: “VLAN 2”,
“status”: “active”
},
“3”: {
“id”: “3”,
“name”: “VLAN 3”,
“status”: “active”
}
}
`
I also have a variable:
vlan: 2
I’d like to do:
- debug:
var: vlan_list[vlan]
This does not work? How can I user the variable “vlan” to get what is the info for VLAN 2 in the dict vlan_list?
Thanks