Howdy,
It appears that most variables and dict values are correctly inherited into
jinja2 templates, however I appear to have found some corner case or known
limitation. I've been skimming both the Ansible & Jinja2 docs and have yet
to find a working solution - my guess is incompatible YAML syntax. Assuming
the following host_vars:
---
uniq_id: 255
vlans: {
2: {
description: "working VLAN 2 on unique host {{ uniq_id }}",
v4_cidr: "192.168.1.1/24",
},
5: {
description: "another example",
v4_cidr: "172.16.230.1/24",
},
"{{ uniq_id }}": {
description: "not working",
}
}
Using the following template:
Working dict {{ uniq_id }} value
{% for vlan in vlans|dictsort %}
Matched VLAN id {{ vlan[0]|string }} for {{ vlan[1].description }}
{% endfor %}
The result is:
Working dict 255 value
Matched VLAN id 2 working VLAN 2 on unique host 255
Matched VLAN id 4 for another example
Matched VLAN id {{ uniq_id }} for not working
The environment is ansible (1.6.3) & jinga2 (2.7.3), again it looks like
substitution works fine for strings and values, but not array keys? Much
appreciate any guidance on what could be happening here, thank you.
--Matt
--
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/1a4823d3-b1d3-4d83-9f2c-0c3fc7a751e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.