`ignore_errors: true` is set, but the play still aborts on that task
AdvancedTroubleshootingModules, Idempotency and Handlers
Answer
Likely causes → ignore_errors only covers a task that ran and returned failed. It does not cover unreachable hosts, undefined variables in the task's arguments, syntax errors or a missing module.
Fix →
- For unreachable hosts, use
ignore_unreachable: true. - For undefined variables, add a
default(), or useblock/rescue, which catches most task-level errors:
- block:
- ansible.builtin.include_tasks: optional.yml
rescue:
- ansible.builtin.debug:
msg: "optional step failed: {{ ansible_failed_result.msg | default('n/a') }}"
Prevent → Prefer explicit failed_when conditions over blanket ignore_errors. ansible-lint flags ignore-errors usage.
More on Modules, Idempotency and Handlers
`ERROR! The requested handler 'Restart nginx' was not found in either the main handlers list nor in the listening handlers list`BeginnerA handler named `restart {{ app_service }}` is never found when notified as `restart myapp`AdvancedA `command` task reports `changed` on every run, and the Molecule idempotence check failsBeginner`curl ... | tar xz` fails on the host but the `shell` task reports successIntermediate`lineinfile` appends the same line again on every runIntermediate`lineinfile` with `backrefs: true` reports `ok` but the line was never addedIntermediate