This is something I have been struggling with for a while: a variable
whose name includes a variable. For instance, Ansible facts for a server
includes the following information on the network interfaces:
"ansible_eth0": {
"active": true,
"device": "eth0",
"ipv4": {
"address": "10.105.12.24",
"netmask": "255.255.252.0",
"network": "10.105.12.0"
},
"macaddress": "00:50:56:92:3c:b2",
"module": "vmxnet3",
"mtu": 1500,
"promisc": false,
"type": "ether"
},
"ansible_eth1": {
"active": true,
"device": "eth1",
"ipv4": {
"address": "10.104.24.25",
"netmask": "255.255.255.248",
"network": "10.104.24.24"
},
"macaddress": "00:50:56:92:6a:40",
"module": "vmxnet3",
"mtu": 1500,
"promisc": false,
"type": "ether"
},
"ansible_interfaces": [
"lo",
"eth1",
"eth0"
],
In a playbook, I want to walk through the list of interfaces and extract
information about each one:
- debug: msg="interface = {{item}}, address =
{{ansible_{{item}}.ipv4.address}}
with_items: ansible_interfaces
when: 'item != "lo"'
This, of course, does not work because of the nested delimiters. So how do
I call out something like this?
-Mark
--
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/54612f0b-cc6f-4c72-9d9c-02c1bc466966%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.