Open main menu

Changes

link to project on GitHub
In at least v2.9 of Ansible, the Template module has options to specify both.
*[https://docs.ansible.com/ansible/2.9/modules/template_module.html 2.9 docs for the template module] []
*[https://docs.ansible.com/ansible/latest/modules/template_module.html latest docs for the template module]
**[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html#parameter-lstrip_blocks parameter lstrip_blocks]
==By hand==
I was so frustrated by the lack of clear examples '''that showed all variants''', I created a project on GitHub called '''[https://github.com/freephile/test-jinja test-jinja]''' that does exactly that. (Inspiration from https://github.com/ansible/ansible/pull/37478)
 
You could also use the [https://github.com/qn7o/jinja2-live-parser jinja2 live parser] project to interactively preview jinja.
If you're confused about Variable notation and how those are defined in templates, see https://jinja.palletsprojects.com/en/3.1.x/templates/#variables
==Debugging==
Just put <code>{% debug %}</code> somewhere in your template file.This didn't work for me in Ansible 2.9
<br />
== More ==