What is idempotency in Ansible and how is it achieved?
⚡
Quick Answer
Running a playbook repeatedly converges to the same state; a second run should report changed=0.
Detailed Answer
Modules check current state before acting — the apt module installs only if the package is absent, template writes only if content differs. Idempotency lets you run playbooks safely and repeatedly. Raw command/shell are NOT idempotent by default; add creates:, removes:, or changed_when: to make them behave.
💡
Interview Tip
Call out that command/shell break idempotency unless guarded.
ansibleidempotencymodules