Comparisons are used in many places with Ansible. Task conditionals are comparisons. Jinja2 control structures such as if/elif/else blocks, for loops, and macros often use comparisons; some filters use comparisons as well. To master Ansible's usage of Jinja2, it is important to understand what comparisons are available.
Comparing values
Comparisons
Like most languages, Jinja2 comes equipped with the standard set of comparison expressions you would expect, which will render a Boolean true or false.
The expressions in Jinja2 are as follows:
Expression | Definition |
== | True if two objects are equal |
!= | True if two objects are not equal |
> | True if the left-hand side is greater than the right-hand side |
< | True if... |