I am using a simple template with only variables in it. This is how my task looks like in my playbook (actually a role being used from my playbook):
- name: Ensure the conf file exists
template:
src: file.conf.j2
dest: '/opt/file.conf'
with_items: '{{ myrole }}'
I keep variables in group_vars. Any variable in file.conf.j2
will be expanded correctly, like {{ myrole_user }}
but fails when expanding one of with_items variables, like {{ myrole.applicationName }}
.
My group_vars looks like this:
myrole_user: regularuser
myrole:
- { applicationName: foo, othervar: bar }
And this is the Ansible error:
"msg": "AnsibleUndefinedVariable: 'list object' has no attribute 'applicationName'"