Quiz Entry - updated: 2026.10.22
What does idempotent mean in Ansible, and why does it matter?
Running the same task or playbook again gives the same end result; if the system is already in the desired state, nothing is changed.
* Running the task again leaves a correct host untouched and reports ok instead of changed. *
Example: a task "make sure package nginx is installed".
- First run: nginx is missing, so Ansible installs it and reports changed.
- Second run: nginx is already installed, so Ansible does nothing and reports ok.
Compare that with a shell script that runs echo "export PATH=..." >> ~/.bashrc: every run appends another line.
Idempotency is what makes it safe to run a playbook many times on the same hosts. You can re-run after a partial failure, run regularly to correct drift, or run against a mix of new and existing servers, without worrying about breaking what is already correct.
Go deeper:
Validating tasks with check mode and diff mode (official docs) — dry runs that rely on modules knowing whether a change is needed.
Idempotence (Wikipedia) — the mathematical and computer-science meaning, with examples such as HTTP PUT/DELETE.