Ansible ignore_errors: Handle Task Failures (Complete Guide)

By Luca Berton · Published 2026-04-03 · Category: installation

Complete guide to Ansible ignore_errors. Handle task failures gracefully, use failed_when, rescue blocks, and control error behavior in playbooks.

By default, Ansible stops playbook execution when a task fails. The ignore_errors directive and related error handling features let you control this behavior.

ignore_errors: true

Continue playbook execution even if a task fails:

Important: ignore_errors still marks the task as "failed" in the output — it just doesn't stop execution.

ignore_unreachable: true

Specifically handle unreachable hosts (different from task failures):

failed_when: Custom Failure Conditions

Define your own failure criteria:

Never fail (always succeed)

changed_when: Control Changed Status

Prevent false "changed" status:

block/rescue/always: Try-Catch Pattern

any_errors_fatal: Stop Everything

Stop the entire playbook across all hosts when any host fails:

max_fail_percentage

Allow a percentage of hosts to fail before stopping:

Practical Examples

Check-and-act pattern

Graceful service management

FAQ

What's the difference between ignore_errors and failed_when: false?

ignore_errors: true marks the task as failed but continues. failed_when: false means the task is NEVER marked as failed. Use failed_when: false for truly inconsequential commands.

Does ignore_errors work with handlers?

Yes, but a failed task won't trigger handlers even with ignore_errors. Use changed_when to control handler triggering.

Can I ignore errors for an entire block?

Yes: put ignore_errors: true on the block directive.

Basic ignore_errors

Check Error and Act

ignore_unreachable

failed_when (Custom Failure Conditions)

block/rescue/always (Try-Catch)

Error Handling Comparison

| Method | Use Case | |--------|----------| | ignore_errors: true | Continue regardless of failure | | failed_when | Custom failure conditions | | block/rescue | Try-catch with rollback | | ignore_unreachable | Handle offline hosts | | any_errors_fatal | Stop ALL hosts on any failure | | max_fail_percentage | Allow some hosts to fail |

any_errors_fatal

FAQ

Does ignore_errors skip handlers?

No — if the task that notified a handler reported changed (even with an error), the handler still runs.

How do I fail the play later based on ignored errors?

What's the difference between ignore_errors and failed_when: false?

Both prevent failure, but failed_when: false means the task never fails (always shows ok/changed). ignore_errors: true still marks it as failed in output but continues.

Basic ignore_errors

ignore_errors vs failed_when

Handle Errors with block/rescue

Conditional Error Handling

ignore_unreachable

any_errors_fatal

max_fail_percentage

changed_when with Error Handling

Common Patterns

FAQ

Does ignore_errors affect handlers?

Yes — if a task with ignore_errors: true notifies a handler and fails, the handler is still triggered (because the play continues).

ignore_errors vs block/rescue?

ignore_errors silently continues. block/rescue lets you execute recovery logic. Use rescue for production workflows.

Does ignore_errors count as a failure?

The task shows as "failed" (red) in output but the play continues. ansible_failed_result is set. Use failed_when: false to not mark it as failed at all.

Basic ignore_errors

Check Result After Ignoring

failed_when (Better Control)

ignore_unreachable

Block/Rescue (Try/Catch)

any_errors_fatal

max_fail_percentage

changed_when with ignore_errors

FAQ

ignore_errors vs failed_when?

ignore_errors continues regardless of failure. failed_when lets you define what constitutes a failure. Prefer failed_when for precise control.

Does ignore_errors affect handlers?

No — handlers still won't run for failed tasks even with ignore_errors. The task is still marked as failed.

How to fail the play later based on ignored errors?

Related ArticlesAnsible Template GuideAnsible Handlers GuideAnsible when Conditional GuideAnsible Inventory GuideAnsible Ignore Errors Guide

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home