Skip to content

Instantly share code, notes, and snippets.

@darkone23
Created October 12, 2013 02:11
Show Gist options
  • Select an option

  • Save darkone23/6944912 to your computer and use it in GitHub Desktop.

Select an option

Save darkone23/6944912 to your computer and use it in GitHub Desktop.
# ansible uses jinja templates for variable substitution
# because of this, you are free to use all of jinja anywhere ansible templates
# for example the arguments to modules
- name: pattern or antipattern? you decide
hosts: local
connection: local
vars:
iferate: no
messages:
- puters
- editors
- woah
message: peas and potatoes
tasks:
- shell: >
{% if iferate %} # do stupid things
{% for message in messages %} echo {{ message }}; {% endfor %}
{% else %}
echo {{ message }}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment