Got it (from http://jinja.pocoo.org/docs/templates, right in "Variables"):
- name: test
debug: msg="database conn string: {{ databases[item].connection_string }}
with_items: db_names
On 2014-07-31 10:41, Yves Dorfsman wrote:
>
> With jinja2, is it possible to use a variable as a key to a dictionary?
> The following doesn't work:
>
> var file:
> db_names:
> - prod
> - dev
> - qa
>
> databases:
> prod:
> connection_string: prod_conn_string
> qa:
> connection_string: qa_conn_string
> dev:
> connection_string: dev_conn_string
>
>
> playbook:
> - name: test
> debug: msg="database conn string: {{ databases.{{item}}.connection_string }}
> with_items: db_names
>
>
--
Yves.
--
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/53DA0B14.5020601%40zioup.com.
For more options, visit https://groups.google.com/d/optout.