Error Handling¶
Section status: outline
This page is scoped but not yet written in full prose. The sections below define what it will cover.
Why This Exists¶
By default, a failed task on one host removes that host from the rest of the play but lets other hosts continue — that default is usually right, but not always, and this page covers the keywords that change it deliberately.
What It Will Cover¶
ignore_errors: true— continue the play on this host past a failed task (rarely the right first instinct; usuallyfailed_whenis)failed_when:— define failure explicitly instead of relying on a module's default success/failure logic (used constantly withcommand/shell, see Command vs. Shell)any_errors_fatal: true— stop the entire play, across all hosts, the moment any single host failsmax_fail_percentage— abort the play once more than a given percentage of hosts have failed, useful for canary-style rollouts- How these interact with
block/rescue/always
Common Mistakes¶
- Reaching for
ignore_errors: trueto silence a failure instead of fixing the underlyingfailed_whenlogic — this hides real problems, not just cosmetic ones. - Not setting
any_errors_fatal/max_fail_percentageon a rollout that should stop early if early hosts are already failing.
Interview Questions¶
- What's the difference between
ignore_errorsandfailed_when? - How would you stop an entire rollout early if 20% of hosts fail?
Next¶
Continue to Imports vs. Includes.