Pcornel
Automation

Error Handling

Cheat sheet · https://pcornel.dk/topic.php?topic=5971

Back to the Topic

Answer

Error handling in automation decides what happens when a step fails: fail fast or continue, retry with backoff, time out, clean up, report clearly and leave systems in a known state.

Remember

  • Fail fast on serious errors.
  • Retry only operations that are safe to repeat.
  • Always clean up and report clearly.

First checks

  • Error classification (retryable vs fatal) — handling
  • Non-zero exit and clear message on failure — signal
  • Cleanup on every exit path — safety

Verify in this order

error → classify → retry/fail → cleanup → report

Where it usually breaks

Automation/controller success is not target-state proof; target config/state is not effective-runtime proof; effective state is not workload proof.

→ Error Handling · operational reference

LayerError Handling operational reference
Runtime/ownershipAutomation error-handling patterns / Ansible current · identify controller/worker/target ownership before mutation
Persistent intentVersioned configuration/playbook/workflow with explicit dependencies and least-privilege identity
Verificationansible-playbook playbook.yml --check -vv; echo exit=$?
Expected interpretationFailures are classified by boundary, retries are bounded, cleanup/compensation is explicit, and automation returns an outcome that callers can distinguish from partial success.
Recovery boundaryPreserve correlation IDs + pre-state, then verify target/service independently after remediation

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5971

Confirmation

Confirm action

Continue?