Skip to content

Instantly share code, notes, and snippets.

@adamchainz
Created May 23, 2015 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamchainz/8bafec17c32981e50fa1 to your computer and use it in GitHub Desktop.
Save adamchainz/8bafec17c32981e50fa1 to your computer and use it in GitHub Desktop.
Ansible template a variable
- hosts: 127.0.0.1
connection: local
gather_facts: no
tasks:
- set_fact:
my_templated_var: |
{
{% for key in ["foo", "bar"] %}
"{{ key }}": 1,
{% endfor %}
"end": 0
}
- debug: var=my_templated_var
- debug: msg="bar is {{ my_templated_var["bar"] }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment