Hands-on Lab·Ansible
Ansible Error Handling with ignore_errors and block
By default a failed task removes that host from the rest of the play while the others carry on - which is neither obviously right nor obviously wrong until you have seen it. This shows the default, then `ignore_errors`, then deciding for yourself what counts as failure, then `block`/`rescue`/`always`, and finally stopping everything at once.
Plays and Playbooks Guide 16 of 45 Intermediate
- OSUbuntu 26.04 LTS
- ansible-core2.20.1
- Python3.14.4
- TimeAbout 17 min
- Reviewed23 August 2026
Written against the versions above. `rescue` makes the play continue: a handled failure is counted as `rescued` rather than `failed`, and the play carries on afterwards. That is what makes block/rescue a real error-handling construct rather than a fancier `ignore_errors`.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| ANS-CTL01 | 192.168.0.36 | Ubuntu 26.04 LTS | Ansible Control Node | 2 Core | 3 GB | 50 GB |
| ANS-A01 | 192.168.0.37 | Ubuntu 26.04 LTS | Managed Node (group: web) | 2 Core | 3 GB | 50 GB |
| ANS-B01 | 192.168.0.38 | Ubuntu 26.04 LTS | Managed Node (group: db) | 2 Core | 3 GB | 50 GB |
Before you start
- A control node configured as shown in the first step.
- The session fails tasks deliberately on
ans-a01and changes nothing on either host.
-
The configuration this guide assumes
-
The default is to stop that host
-
Ignoring an error
-
Deciding yourself what counts as failure
-
block, rescue, always
-
One host failing versus all of them