Use it when the symptom is “Idempotency Failure”: work through the layers in order and stop at the first one that fails.
Idempotency Failure
Idempotency Failure isolates automation that changes state or creates side effects on repeated execution despite already having reached the intended state.
1. Idempotency failure: rerun changes something every time.
2. Find the task.
3. Guard commands, avoid timestamps, normalise comparisons.
4. Add idempotence test.
5. Fix and verify.
run twice → changed>0 → find task → fix
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
ansible-playbook --check --diff <playbook.yml>Primary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
desired state → current-state read → normalization/comparison → planned operation → target mutation → read-back → second identical run → residual diff/side effects → acceptance
Healthy evidence: converged state is explicit, repeat runs produce no unexplained target mutation or external side effect, and workload acceptance remains healthy.
Step 2 Telling causes apart Verify boundary
Known-good is a second identical run/read-only check reporting no unintended changes and direct target state remaining equal to the desired state; a deliberate drift should be detected and corrected exactly once. Broken evidence is recurring diff/change on unchanged input or target values oscillating between runs. The check result should report success with the relevant change count at 0 after convergence; a non-zero recurring change count is broken state. --check --diff is supporting evidence only because check mode may be incomplete; durable idempotency requires repeated target read-back under the same inputs.
Step 3 Common mistakes Verify boundary
- Tasks that always report changed.
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: every run reports changes from timestamps/order, non-idempotent create calls are repeated, changed=0 is treated as service evidence, or drift is silently ignored.
Step 5 Observation-driven branch and next-check logic Narrow the fault
After a controlled successful apply, run ansible-playbook --check --diff <playbook.yml> with identical inventory/variables. If it still reports changes, inspect the first changed task and diff for unstable data, command/shell use, missing creates/removes guards or comparison normalization. If check mode reports clean but real runs still change, confirm module check-mode fidelity and inspect runtime-generated values. Compare two successive real read-backs in a safe environment rather than simply adding changed_when: false to silence the symptom.
Step 6 Where it fails Narrow the fault
Where Idempotency Failure usually goes wrong: stable operation key, desired/current-state comparison, no-op behavior and duplicate-mutation prevention.
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.
- Second run changed ≠ change was necessarily harmful, but it requires explanation.
- changed=0 ≠ workload/service is healthy.
- Same desired input ≠ provider/API returns stable normalized state.
- No textual diff ≠ no external side effect occurred.
- Second run shows changes — symptom
- Task causing change each run — culprit
- Normalisation of compared values — fix
ReferenceWhat it is1 section · depth on demand
Core model
Run against a known converged target; capture before/after state and operation diff; determine whether detection logic, normalization, unstable ordering, generated values, timestamps, API defaults or non-idempotent endpoints cause repeated change; fix comparison/reconciliation; rerun until no unintended mutation while acceptance stays green.
ReferenceHow it works1 section · depth on demand
How it works and how it fails
Idempotency Failure means the same desired input produces repeated unnecessary changes or divergent state after the first convergence. Causes include volatile inputs, non-idempotent modules/commands, unstable ordering, timestamps/random values or incomplete state detection. The reconciliation engine owns desired-versus-current state comparison and applies module logic through downstream target dependencies; check-mode state is separate from a real apply. ansible-playbook --check --diff estimates change intent against current state, but module check-mode support varies; it is a diagnostic projection, not guaranteed no-side-effect execution.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
An idempotent rerun shows convergence only for the observed state model and side effects, but it does not show broader service health or hidden external actions.
Method
An idempotency failure is automation that reports changes (or makes changes) on every run even though nothing should differ. Finding it follows a method.
1. Run twice and list tasks that report changed on the second run.
2. For each, compare what it reads with what it writes (diff output).
3. Look for unstable inputs: timestamps, random values, unordered lists, generated passwords.
4. Look for commands without state checks (command, shell, raw API POST).
5. Fix by normalising, sorting, adding changed_when/creates, or using a state-aware module.
| Typical cause | Fix |
|---|---|
Template contains {{ ansible_date_time }} | Remove volatile content |
| Device normalises config differently | Match device format in desired state |
| POST instead of PUT | Check existence first |
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Automation Troubleshooting > Idempotency Failure. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/azure/architecture/patterns/retry · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Idempotency Failure troubleshooting proof-boundary map
Fast symptom/scope, first-failed-boundary, effective-outcome and recovery/closure map for Idempotency Failure.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Symptom / scope | Time window, immutable source/run identity, effective inputs and exact targets are explicit | Floating source, changed inputs or ambiguous targets destroy reproducibility |
| First failed boundary | Transport/auth/dependency/render/operation evidence identifies the earliest divergence | Investigation starts at the final error and skips earlier unproven boundaries |
| Effective outcome | Controller result is paired with target read-back and workload/service acceptance | Green execution state or changed symptom substitutes for effective-state verification |
| Recovery / closure | Minimal change restores the original test and regression/partial-state checks are clean | Broad retry or unrelated edits make the incident non-reproducible and hide residual state |
Deep reference
Healthy vs suspicious evidence
Output interpretation
For Idempotency Failure, rely on structured fields and stable IDs (stable operation key, desired/current-state comparison, no-op behavior and duplicate-mutation prevention) rather than text formatted for display.