I am trying to pass an Ansible variable to an if/then/else statement in Jinja, but it is not recognizing it as a variable. I know the "stacked mustaches" are not supported, but I also tried the square brackets [ ] and that didn't work either. Can anyone clue me in on a way to do this? This works when I am put an actual value in there for {{ protection_type }}, but not when I try to use a variable.
Basically, I'm just checking to see if a particular string exists within the "volume_comment" variable:
ansible.builtin.set_fact:
protection_present:
"{%- if volume_comment | regex_search('.*{{ protection_type }}.*') -%}
false
{%- else -%}
true
{%- endif -%}"