Pcornel
Automation · Automation Fundamentals

Idempotency

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

Back to the Topic

Answer

Idempotency means repeated application of the same desired request converges on the same intended state without accumulating unintended side effects.

Remember

  • Idempotent ≠ no-op on every rerun; a rerun may correctly repair drift.
  • Idempotency ≠ determinism; timestamps, generated IDs or API metadata may differ while the managed state still converges.
  • Idempotent module ≠ idempotent workflow; ordering and external side effects can break end-to-end idempotency.
  • Create-if-missing ≠ safe retry automatically; partial failure and duplicate-request semantics must be understood.

First checks

  • ansible-playbook site.yml --check --diff — changes only when needed
  • terraform plan -detailed-exitcode — exit 0 = no changes
  • Second run reports no changes — idempotency proof

Verify in this order

desired state → compare current → change only differences

Where it usually breaks

An idempotent task proves convergence for its defined managed state; it does not guarantee the surrounding workflow or external side effects are idempotent.

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

Idempotency automation boundary map

BoundaryHealthy evidenceSuspicious evidence
Intent / inputsOwner, scope and authoritative inputs are explicit and versioned where applicableHidden defaults, stale inventory or competing sources of truth
Decision / executionPlan or decision is explainable and actions are bounded per targetBlind fan-out, implicit assumptions or success based only on executor status
State / verificationTarget is re-observed and acceptance criteria prove the intended outcomeNo read-back, perpetual drift, partial side effects or unresolved exceptions
Recovery / evidenceRetry, rollback or escalation behavior is defined and auditableUnknown partial completion, unsafe retry or evidence lost during remediation

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

Confirmation

Confirm action

Continue?