The template looks like this:
solr.replication.master= {% if ansible_eth0.ipv4.address == servermaster.eth0 %} false {% else %} true
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.