How do I get an Ansible template to honor new lines after a conditional

前端 未结 5 751
误落风尘
误落风尘 2020-12-14 16:30

The template looks like this:

solr.replication.master=
    {% if ansible_eth0.ipv4.address == servermaster.eth0 %}
        false
    {% else %}
        true
         


        
5条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 16:48

    I had the same issue. I solved it by adding

    {{''}}
    

    to the end of the line, for example:

    solr.replication.master={% if ansible_eth0.ipv4.address == servermaster.eth0 %}false{% else %}true{% endif %}{{''}}
    

    This inserts an empty string literal, with the side effect that whitespace is not stripped.

提交回复
热议问题