Using ansible 2.7.5 I am trying to create a multi-line boolean parameter.
I first verified that it works as expected as one-line with:
FOOD: apple
IS_FRUIT: '{% if FOOD == "carrot" %}false{% elif FOOD == "apple" or FOOD == "banana" %}true{% endif %}'
and then a task:
- name: "FOOD is: {{ FOOD }}" 
  debug: msg="FOOD is {{ FOOD }} where IS_FRUIT {{ IS_FRUIT | bool }}"
which prints:
ok: [localhost] => {
    "msg": "FOOD is apple where IS_FRUIT [ True ]"
}
as expected when run.
Based on:
In YAML, how do I break a string over multiple lines?
I have then tried:
IS_FRUIT: >-
 {% if FOOD == "carrot" %}false
 {% elif FOOD == "apple" or FOOD == "banana" %}true
 {% endif %}
but that prints:
ok: [localhost] => {
    "msg": "FOOD is apple where IS_FRUIT [ False ]"
}
which is wrong. I found this post describing a similar issue: https://github.com/ansible/ansible/issues/18142
but it does not really provide a solution. Any suggestion on how to create multi-line boolean variables in Ansible?
Based on below answer I have also tried:
FOOD: apple
IS_FRUIT: |
 {% if FOOD == "carrot" %}false
 {% elif FOOD == "apple" or FOOD == "banana" %}true
 {% endif %}
but when I run that with the same task above I still get:
ok: [localhost] => {
    "msg": "FOOD is apple where IS_FRUIT False"
}
which is wrong.
 
     
     
     
    