How do you combine several conditions?
BeginnerConceptJinja2, Conditionals and Loops
Answer
Write them with and/or, or give when a list, which means AND.
when:
- ansible_facts['os_family'] == 'Debian'
- ansible_facts['distribution_major_version'] | int >= 22
- deploy_enabled | bool
For OR with grouping, use parentheses: when: (a == 1 or b == 2) and c.
More on Jinja2, Conditionals and Loops
What role does Jinja2 play in Ansible?BeginnerWhat are the three Jinja2 delimiters?BeginnerShow a template with a loop and a conditional, and how it is deployed.BeginnerWhich filters do you use every day?BeginnerHow do you transform lists and dicts with filters (`map`, `select`, `selectattr`, `unique`, `flatten`)?IntermediateHow does `when` work and which operators can you use?Beginner