TOPIC DEVOPS
Idempotency why running twice must be safe
IN 10 SECONDS
A property where executing an operation multiple times produces the exact same result as executing it once, preventing resource duplication or configuration errors.
GOTCHA Shell commands (like curl or bash redirection) are not idempotent. You must add guard checks to prevent them from executing repeatedly.
HOW IDEMPOTENT RUNS FLOW
01 First execution playbook/script runs, detects resource missing, and creates it.
02 Second execution runs, detects resource already exists, and reports ok (no changes).
03 Failsafe check operations evaluate current state before modifying resource attributes.
04 Result system stays in the desired configuration state without duplicating objects.
POKE IT YOURSELF
ansible-playbook --check playbook.yml — verify if tasks will make changes without altering target state
mkdir -p my-dir — idempotently create a directory (succeeds even if folder exists)
Drill this topic →
~60 sec read