Pcornel
Automation · Automation Design

Idempotency

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

Back to the Topic

Answer

Idempotency as a design principle means every step checks state before acting, so the whole job can be rerun safely after a partial failure without creating duplicates or breaking things.

Remember

  • Each step checks state first.
  • Reruns must not duplicate resources.
  • Prove it by running twice.

First checks

  • ansible-playbook site.yml && ansible-playbook site.yml — second run changed=0
  • terraform plan -detailed-exitcode — 0 after apply
  • Guarded imperative steps (creates/unless) — safety

Verify in this order

desired state → check → change only if needed

Where it usually breaks

Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.

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

Confirmation

Confirm action

Continue?