Use this when automation may run many times.
Repeated Execution
Repeated execution means automation can safely run again after a failure, on a schedule or by mistake, because idempotent steps skip work that is already done.
1. Repeated execution should be safe and stable.
2. Enables scheduled enforcement.
3. Detects non-idempotent tasks.
4. Track changed counts over time.
5. Investigate recurring changes.
run → rerun → stable results
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
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 Verification path Verify boundary
Record run ID, target object ID, desired revision and comparison key/version; inspect the runtime/control-plane result; then query the target object in the intended state with no duplicate or unnecessary side effect on repeat through an independent read path and compare it with the versioned intent. For Idempotency → Repeated Execution, the evidence must connect the control-plane result to the target object in the intended state with no duplicate or unnecessary side effect on repeat and explain any gap between desired, controller-reported and consumer-visible state.
Step 2 Common mistakes Narrow the fault
- Running only once in tests.
Step 3 Where it fails Narrow the fault
Failure analysis for Idempotency → Repeated Execution should follow the path through the components: desired intent → target read → normalize/compare → decide no-op/change → mutate → read-back → second-run no-op evidence. Common failure classes include ambiguous lookup, stale read, race between read/write, generated values causing perpetual diff, duplicate creation and declaring idempotency without second-run evidence. Before retrying a mutating operation, read current target state using the stable identity run ID, target object ID, desired revision and comparison key/version; if state is unknown, stop broad retries.
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.
- Jobs may run again after failure, on schedule or by mistake.
- Idempotent steps skip completed work.
- Reruns must not duplicate resources.
ansible-playbook site.yml; ansible-playbook site.yml— repeat- Scheduled re-runs for enforcement — drift correction
- Results stable across runs — determinism
ReferenceWhy it matters1 section · depth on demand
Method
Repeated execution testing checks that an automation can run any number of times with the same inputs and still produce a correct, unchanged system.
1. Run against a clean target and record changes.
2. Run again immediately; expect zero changes.
3. Introduce a small manual drift; run again and expect only that drift corrected.
4. Interrupt a run midway; rerun and expect a complete, correct result.
5. Run concurrently twice (if applicable) and check for duplicates.
| Failure | Cause |
|---|---|
| Changes on every run | Non-idempotent command, unstable ordering |
| Duplicate objects | Create without existence check |
| Rerun after interruption fails | Partial state not handled |
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
Idempotency → Repeated Execution is owned at runtime by the automation engine and target read/write interface evaluating whether desired and actual state differ. Its durable intent is versioned desired-state operation with stable identity, comparison semantics and minimal mutation policy; the stable identity contract is run ID, target object ID, desired revision and comparison key/version. The consumer-visible target is the target object in the intended state with no duplicate or unnecessary side effect on repeat. The operating invariants are that identity is stable, comparison normalizes equivalent state, repeated execution is no-op, retries are safe and concurrent changes do not cause duplicate creation/update. Follow the chain of components desired intent → target read → normalize/compare → decide no-op/change → mutate → read-back → second-run no-op evidence and record which layer currently owns truth. The linked authority for bounded mechanics is Ansible Documentation — Idempotency and desired state; documentation support is separate from observed lab/production Evidence.
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 Idempotency > Repeated Execution. 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%Deep reference
Healthy vs suspicious evidence
Output interpretation
Capture at minimum target ID, desired revision, before/after values, diff, changed/no-op flag, retry/attempt, error and second-run result.