I have a question about the use of group_vars in Ansible. I would like to use the data dictionaries values from swtich.json, I also need it to be global set of values almost like all. When I call it in Ansible it becomes unknown... Is there a way to do it?
Ansible debug output:
TASK [basebmc : debug] *********************************************************
task path:
/mnt/c/Users/emarq/Documents/Source/Repos/Solutions.Network.Automation/MAS/Ansible/hpe/roles/basebmc/tasks/main.yml:20
fatal: [b43-1u15-d00-5900AFbmc]: FAILED! => {
"failed": true,
"msg": "the field 'args' has an invalid value, which appears to include a
variable that is undefined. The error was: dict object has no element
5900\n\nThe error appears to have been in
'/mnt/c/Users/emarq/Documents/Source/Repos/Solutions.Network.Automation/MAS/Ansible/hpe/roles/basebmc/tasks/main.yml':
line 20, column 3, but may\nbe elsewhere in the file depending on the exact
syntax problem.\n\nThe offending line appears to be:\n\n\n- debug:\n ^ here\n"
}
group_vars/
baseagg.yml basebmc.yml basetor.yml switch.json
Ansible.hosts:
[swtich:children]
basebmc
[basebmc]
bmcdevice1
Role baesbmc/tasks/main.yml:
- debug:
msg: "name: {{ inventory_hostname }} {{ portmap.HPE.5900.Port.46.Port }}"
verbosity: 4
with_dict: "{{ portmap }}"
playbook.yml
---
# Setup playbook to deploy a switch NTP settings using common
- name: BMC base config
hosts: basebmc
remote_user: admin
gather_facts: no
connection: local
roles:
- basebmc
switch.json
{
"portmap": {
"HPE": {
"5900": {
"DEVICETYPE": "BMC",
"Port": {
"46": {
"Type": "GigabitEthernet",
"Port": "1/0/46"
},
"management": {
"Type": "M_GigabitEthernet",
"Port": "0/0/0"
}
}
}
}
}
}
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/BN6PR03MB272371600683606920DE3B34DD9C0%40BN6PR03MB2723.namprd03.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
<<attachment: winmail.dat>>
