Interview Prep/Ansible/Modules, Idempotency and Handlers

`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 use block/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.

All Ansible questions Roadmap: Ansible

More on Modules, Idempotency and Handlers