Quiz Entry - updated: 2026.12.01
Which tool would you use for each of these: a task that is expected to fail, a restart that must survive a later failure, a script that prints an error but exits 0, a read-only command, and an upgrade that must be rolled back on failure?
ignore_errors, force_handlers, failed_when, changed_when: false, and block with rescue (plus always for clean-up).
| Situation | Tool | Effect |
|---|---|---|
| A failure is expected and harmless | ignore_errors: true |
The play continues on that host |
| A queued restart must not be lost when a later task fails | force_handlers: true (play) |
Notified handlers still run |
| Exit code 0, but the output says it failed | failed_when: <condition> |
You define what failure is |
| A command only reads, nothing changes | changed_when: false |
Reports ok, notifies no handlers |
| A multi-step change must be undone on failure | block / rescue / always |
Recover, then clean up in every case |
All five change the same thing: how a task's result (ok, changed, failed) is interpreted and what follows from it. The first four act on a single task or play. Blocks act on a group of tasks, which makes them the only tool for "if any of these steps fails, do this instead".
Go deeper:
Error handling in playbooks (official docs) — all of these tools in one place.
Controlling errors in blocks (official docs) — how rescue interacts with the other settings.