I have the need to template a yaml file using vars in another yaml file as
input.  There are often defaults.

I'd like to do this

in vars.yml
parentvar:
  childvar:
    subvar1: val1
#  subvar2 is not even listed to keep user vars.yml file concise

template.yml
{{ parentvar.childvar.subvar1 }}
{{ parentvar.childvar.subvar2 | default("default for subvar2") }}

This fails with "dict object has no attribute 'subvar2'

It would work fine if i had
vars.yml
parentvar_childvar_subvar1: val1

and template.yml
{{ parentvar_childvar_subvar1 }}
{{ parentvar_childvar_subvar2 | default("default for subvar2") }}

I presume this is a problem at the jinja2 level?

I would like to avoid the '_' flattened solution as it becomes pretty
unreadable for large config files.
Any suggestions on how to work around this?

thanks

Kesten Broughton
512 701 4209

-- 
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/CAO2fFsVRHaaqdZrJ2idE_JUR2HDOkcbuxP%3DjqkDUecBda%3DsbRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to