Hi,
I have some issues with for loop in jinja2 template. In
hosts_vars/name_of_host i have defined:
add_php_packages:
- php5-xcache
apps:
- {
...
postgres: {
db_host: 'xxx',
db_user: 'xxx',
db_name: 'some_name',
db_pass: 'xxx',
db_port: 5432
},
...
}
Than task:
- name: Generate /etc/system.monitoring/config.cfg
action: template src=etc/system.monitoring/config.cfg.j2
dest=/etc/system.monitoring/config.cfg owner=root group=root mode=0644
And in template:
{% for db in apps['postgres']['db_name'] %}
check.pg_locks_{{ db }}.env.PGDATABASE={{ db }}
{% endfor %}
This give me error:
fatal: [uc4qaap01] => {'msg': "One or more undefined variables: 'list
object' has no attribute 'postgres'", 'failed': True}
fatal: [uc4qaap01] => {'msg': 'One or more items failed.', 'failed': True,
'changed': False, 'results': [{'msg': "One or more undefined variables:
'list object' has no attribute 'postgres'", 'failed': True}]}
When i use for example:
{% for db in add_php_packages %}
check.pg_locks_{{ db }}.env.PGDATABASE={{ db }}
{% endfor %}
Everything is fine and i get this line:
+check.pg_locks_php5-xcache.env.PGDATABASE=php5-xcache
What am i doing wrong?
--
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/d17bab20-c651-4d7a-94d8-dcdc7a886dfd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.