template substitution

If I have in a template file

I normally write it like this:

{% if i_want_yes %}
# yes
{% else %}
# no
{% endif %}

Would that work for you?

Johannes

ansible uses the trim_blocks setting when invoking jinja, by default its ‘yes’.

ansible allows for overrides by creating a special header:

#jinja2: trim_blocks: False
#
# {% if i_want_yes %} yes {% else %} no {% endif %}
#

Many thanks for this information. For future reference where is this documented?

The interaction of ansible with jinga2 seems a bit opaque.

Many thanks for this information. For future reference where is this
documented?

https://groups.google.com/forum/#!topic/ansible-project/qHyIjyal_Ic is a
thread where it came up before, which says

  you can use a per template header to override this, you can see an
  example in the template docs.

  https://docs.ansible.com/template_module.html

which is now at http://docs.ansible.com/ansible/template_module.html, and
which only seems to mention it in a note saying

  Since Ansible version 0.9, templates are loaded with trim_blocks=True.

and not any actual examples, or any explanation of what trim_blocks does,
so it could be hard to spot this if you didn't already know what you were
looking for.

The interaction of ansible with jinga2 seems a bit opaque.

That page also doesn't mention
http://docs.ansible.com/ansible/playbooks_filters.html, which I've found
to be super useful in turning up examples of Ansible-specific Jinja filters.

                                      -Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.