Your `vlan_list` is keyed with strings, not integers.  So you would either
need to set `vlan: "2"` so that `vlan` is a string, or use
`vlan_list[vlan|string]` in your debug.

On Fri, Dec 13, 2019 at 9:29 AM Spiro Mitsialis <[email protected]>
wrote:

> 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
>
> --
> 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/b75a64bd-c0d5-4aab-b190-51eb662975df%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/b75a64bd-c0d5-4aab-b190-51eb662975df%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v9jwNnHQLRTOCzW96dn_B9q8ptWM8QLz2jL6RvGuo%3DBnw%40mail.gmail.com.

Reply via email to