I have a simple vlan config file which I like to have the keys to match with JunOS syntax (this way I can pass them as aggrogate if I need to), so I'm using the vlan-id key like this example variable file.
# vlans.yaml
vlans:
- name: general
description: "General"
vlan-id: 100
- name: hotline
description: "Accounting"
vlan-id: 110
but i can't access the vlan-id key because of the hyphen
- debug:
msg: "{{ item.vlan-id }}"
loop: "{{ vlans }}"
tags: debug
"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'vlan'
if I output the item directly I can see the key
- debug:
msg: "{{ item }}"
loop: "{{ vlans }}
ok: [SW02] => (item={'name': 'external', 'description': 'External', 'vlan-id': 209}) => {
"msg": {
"description": "External",
"name": "external",
"vlan-id": 209
}
}
ok: [SW01] => (item={'name': 'external', 'description': 'External', 'vlan-id': 209}) => {
"msg": {
"description": "External",
"name": "external",
"vlan-id": 209
}
}
Any ideas how to solve this?