Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Idempotency · Configuration Management

Direct answer

Idempotency in configuration management means each resource or module only changes a system when it differs from the desired state, so runs can repeat without side effects and report 'ok' when nothing changed.

When to use this

Use this when making configuration management runs safe to repeat.

First 30 seconds

1. Idempotency: rerun changes nothing.

2. Guard command/shell with creates/changed_when.

3. Test with double runs (Molecule idempotence).

4. Avoid timestamps in templates.

5. Required for safe enforcement.

Operational verification

run → state matches → no changes on rerun

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
configuration management 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.

Platformconfiguration management 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 configuration management runs safe to repeat.
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.

3 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 ambiguous target identity, stale inputs, partial success, unsafe retry, permission drift and confusing tool completion with target-evidence of the actual state, 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 What it is Narrow the fault

Idempotency means running the same automation again changes nothing if the state is already correct; the second run should report changed=0.

Step 3 Common mistakes Narrow the fault
  • Tasks that always report changed.
  • Appending lines to files 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
  • Modules check before changing.
  • 'ok' means no change.
  • Shell commands need guards.
Key checks
  • ansible-playbook site.yml; ansible-playbook site.yml — second run changed=0
  • ansible-lint (no-changed-when) — command tasks flagged
  • changed_when/creates on commands — guarded
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 & boundaries2 sections · depth on demand

In depth

Idempotency in configuration management means applying the same configuration again changes nothing when the system is already correct. It is what makes configuration management safe to run on a schedule to correct drift.

How tools achieve it: each resource compares current state with desired state and changes only differences. It breaks when playbooks use raw commands, append to files, or generate content that differs each run (timestamps, random ordering).

# Not idempotent
- ansible.builtin.shell: echo "server 10.0.0.123" >> /etc/chrony.conf
# Idempotent
- ansible.builtin.lineinfile:
    path: /etc/chrony.conf
    line: "server 10.0.0.123 iburst"

Test: run twice; the second run must report no changes.

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 docconfiguration management automation current

Authoritative/upstream documentation reviewed for bounded claims in Configuration Management > 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?