when condition

A task keyword holding an expression; the task runs on a host only if the expression is true there, and is reported as skipped otherwise.

In more detail

It is written as a bare Jinja expression without double curly braces, as in when: ansible_facts.os_family == 'Debian'. It can compare variables, test facts or check registered results, and can be put on a whole block. Mind the types: a text value such as "false" is not the same as the Boolean false.

Related terms

Taught in

References

Certification courses