LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

If a block has a when condition that is false, do its rescue and always sections still run?

No. A when on the block also applies to its rescue and always sections; if the condition is false, the whole construct is skipped.

The condition guards the block as a unit. If the block's tasks don't apply to this host (say it is not a Red Hat system), there is nothing to rescue and nothing to clean up, so skipping always as well is the consistent behaviour.

This differs from the try/finally intuition that always always runs: it always runs once the block has started, on success or failure, but not when the block was skipped by its condition. If you need a step that runs on every host regardless of the condition, put it in a normal task outside the block.

Go deeper:

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