如何获得 Ansible 模板以在条件之后兑现新行 [英] How do I get an Ansible template to honor new lines after a conditional
本文介绍了如何获得 Ansible 模板以在条件之后兑现新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
模板如下所示:
solr.replication.master=
{% if ansible_eth0.ipv4.address == servermaster.eth0 %}
false
{% else %}
true
{% endif %}
solr.replication.slave=false
输出应该是这样的:
solr.replication.master=true
solr.replication.slave=false
我实际得到的是:
solr.replication.master=truesolr.replication.slave=false
我知道 Jinja2 会去除空格,并且 ansible 可能默认配置了这一点.但它似乎不尊重 -/+ 空白标签.
I understand that Jinja2 strips whitespace, and that ansible is probably configuring this by default. But it does not seem to honor -/+ whitespace tags.
有没有办法强制换行?
推荐答案
将以下行添加到模板的第一个位置:
Add the following line to your template at first position:
#jinja2: trim_blocks:False
这篇关于如何获得 Ansible 模板以在条件之后兑现新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文