Interview Prep/Ansible/Jinja2, Conditionals and Loops

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.

All Ansible questions Roadmap: Ansible

More on Jinja2, Conditionals and Loops