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:
Jinja2 is a templating system and Ansible has a variable system that allows Jinja2 evaluation of recursive value references, but we don’t run it wholesale across the file, it’s run on the keys.
Thus, you cannot have the name of a key in a dictionary in Ansible that is a variable, for instance.
(If this differed in value between different hosts, it wouldn’t make any sense to the system, among other things)
Right, I understand what Jinga2 is… Do you have an alternative approach? Thanks.
I don’t have a solution for what you are trying to do with variable named keys, but let’s step back and try to understand the use case you are trying to model and we can recommend a way to do that.
Can you talk about what you are deploying and configuring and why you think you may need the above idea?