我如何获得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屋!
查看全文