Hello,
I'm trying to compose a variable name with another variable, to keep the variables for each host on a single file/definition.
It looks like the following:
vars.yml:
netconf:
iface:
eth1
ip:
host-1:
172.16.1.100
host-2:
172.16.1.101
mask:
host-1:
255.255.255.252
host-2:
255.255.255.252
Inventory:
[test]
host-1
host-2
playbook.yml:
- hosts: test
- tasks:
- debug: msg="{{ netconf.ip.{{ ansible_hostname }} }}"
I know it can be done loading a different vars file for each host, but I would like to keep them together on a single file. Also this composition schema can be applied to other situations.
Anyone knows if It's possible to achieve that behavior?
BR,
Antonio