LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

What does it mean when when is given a YAML list of conditions instead of one expression?

All conditions in the list must be true: a list is combined with and.

A when list of two conditions is evaluated as condition one and condition two; there is no list form for or

* A when list means and. For or you need one expression. *

These two are equivalent:

when: ansible_facts['distribution_version'] == "9.0" and ansible_facts['kernel'] == "5.14.0-70.13.1.el9_0.x86_64"
when:
  - ansible_facts['distribution_version'] == "9.0"
  - ansible_facts['kernel'] == "5.14.0-70.13.1.el9_0.x86_64"

The list form is easier to read and to change: every requirement sits on its own line, and adding or removing one is a one-line diff. Readability is a real goal in playbooks, because they are read by colleagues far more often than they are written.

The catch: there is no list form for or. If any alternative is acceptable, it has to be one expression joined by or.

Go deeper:

From Quiz: ITIA / Ansible Task Control: Loops, Conditionals, Handlers and Error Handling | Updated: Nov 12, 2026