Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Idempotency · Automation Design

Direct 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.

When to use this

Use this when making a job safe to rerun after partial failure.

First 30 seconds

1. Design every step to be idempotent.

2. Check state before acting.

3. Use declarative modules.

4. Test by running twice.

5. Idempotency enables safe retries and resume.

Operational verification

desired state → check → change only if needed

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
idempotent configuration automation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformidempotent configuration automation · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when making a job safe to rerun after partial failure.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification path Verify boundary

The negative fixture should deliberately exercise risks such as implicit defaults, hidden dependencies, duplicate dispatch, worker drift, timeout without cancellation, retries against non-idempotent operations and confusing control-plane completion with target convergence, choosing the cases most relevant to repeated execution against unchanged desired state should produce a no-op, while drift or changed intent produces the minimal required mutation.

Step 2 Common mistakes Narrow the fault
  • Tasks that report changed on every run.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Each step checks state first.
  • Reruns must not duplicate resources.
  • Prove it by running twice.
Key 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
ReferenceWhy it matters1 section · depth on demand

Internals and state

Idempotency means repeated execution converges without unintended change; it does not by itself show the desired state is correct or useful.

ReferenceImportant terms & boundaries1 section · depth on demand

In depth

Idempotency means running the same automation twice gives the same result as running it once: the second run finds everything already correct and changes nothing. It is the property that makes automation safe to re-run after a failure, on a schedule, or by someone who is unsure whether it already ran.

How to achieve it: describe the desired end state instead of actions ("VLAN 20 exists with name USERS" rather than "run vlan 20"), compare current state with desired state before acting, and report changed only when something was actually modified.

Test: run twice in a row; the second run must report zero changes. Any change on the second run points to a non-idempotent step — commonly shell commands, timestamps written into files, or templates that render differently each time.

ansible-playbook site.yml --check --diff     # preview
ansible-playbook site.yml && ansible-playbook site.yml | tail -3   # second run: changed=0
Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docidempotent configuration automation current

Authoritative/upstream documentation reviewed for bounded claims in Automation Design > Idempotency. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_intro.html · confidence 94%
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

For repeated execution against unchanged desired state should produce a no-op, while drift or changed intent produces the minimal required mutation, prefer typed fields and stable IDs over human presentation text.

Confirmation

Confirm action

Continue?