Is there anything in jinja templating to "eval" a variable name? Where I
can add a string to a variable, and reference another variable
I'm interesting in doing something like this (example pseudocode)
#print the mac addresses and driver (or similar)
{% for interface in ansible_interfaces %}
{{ interface }}
mac= {{ eval('ansible_' + interface).macaddress }}
driver = {{ eval('ansible_' + interface).module }}
{% endfor %}
Where the host variables are like this ( an example ):
"ansible_interfaces": [
"eth1",
"eth2"
],
"ansible_eth1": {
"active": false",
"device": "eth1",
"macaddress": "00:00:00:FF:FF:FF",
"module": "igb",
"mtu": 1500,
"type": "ether"
},
"ansible_eth2": {
"active": false",
"device": "eth2",
"macaddress": "AA:00:00:FF:FF:AA",
"module": "ixgbe",
"mtu": 9000,
"type": "ether"
},
Is something like this possible, or do I have to some combination of
templating using with_items, and then using assemble to stick it together?
--
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].
For more options, visit https://groups.google.com/groups/opt_out.