The template looks like this:
solr.replication.master= {% if ansible_eth0.ipv4.address == servermaster.eth0 %} false {% else %} true {% endif %} solr.replication.slave=false
And the output should look like this:
solr.replication.master=true solr.replication.slave=false
What I am actually getting is:
solr.replication.master=truesolr.replication.slave=false
I understand that Jinja2 strips whitespace, and that ansible is probably configuring this by default. But it does not seem to honor -/+ whitespace tags.
Is there a way to force a line break?
Ansible uses Jinja2 templating to enable dynamic expressions and access to variables and facts. You can use templating with the template module.
We need to have two parameters when using the Ansible Template module, such as: src: The source of the template file. It can be a relative and absolute path. dest: Dest is the destination path on the remote server.
Ansible templates are typically saved as . tpl files and support the use of variables, loops, and conditional expressions. Templates are commonly used to configure services based on variable values that can be set up on the playbook itself, in included variable files, or obtained via facts.
It is a text-based template language and thus can be used to generate any markup as well as source code. The Jinja template engine allows customization of tags, filters, tests, and globals. Also, unlike the Django template engine, Jinja allows the template designer to call functions with arguments on objects.
Add the following line to your template at first position:
#jinja2: trim_blocks:False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With