> > 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 when: item.unit_number|int == disk_unit|int On Friday, 13 September 2019 12:58:10 UTC+1, Karl Auer wrote: > > What does "no longer works" mean? What did you expect, what did you get? > > The warning is correct - you should not use the braces in a when statement. > > 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.... > > Regards, K. > > > On Fri, Sep 13, 2019 at 7:42 PM MKPhil <[email protected] <javascript:>> > wrote: > >> >> 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. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/92770bd7-d206-4a8c-83a8-0c949313557d%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/92770bd7-d206-4a8c-83a8-0c949313557d%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Karl Auer > > Email : [email protected] <javascript:> > Website: http://2pisoftware.com > > GPG/PGP : 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E > Previous: 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816 > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b9b0d0d4-a868-4255-9b4b-3394820a0447%40googlegroups.com.
