I’m trying to compare two variables in a “when” statement - when x = y do something.
This code works:
when: unit_number == {{ disk_unit }}
BUT I get a warning:
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: unit_number == {{ disk_unit }}
If I remove the {{ }} the statement no longer works. How should I write the statement so it works and doesn’t give the warning? I’ve tried various combinations of double and single quotes and round brackets.
This is a genuine warning and was added to the 2.3 release purposefully.
You don’t need to use any special character at all and it will get rid of the warning.
I’m not sure, but it sounds a bit as if the things you are comparing do not contain the values you think they do…
That was the problem! Even though both variables looked like ints when displayed with debug one or other of them wasn’t. I explicitly converted them to int and it now works