Ravindra BagaleCourses & study guides

Chapter 11: Ansible Introduction

11.4 Idempotence — run twice, safe result

Idempotent (practical meaning here): running the playbook again should not wreck the system. Modules aim for "desired state" — state=present, state=started.

Not idempotent habit Better
Shell: always echo x >> file copy/lineinfile with clear content
Blind reboot every run Reboot only when required (handlers)
Delete and recreate blindly Declare final state

Shell modules exist (ansible.builtin.shell) but overusing them throws away Ansible's strengths. Prefer package/file/service modules first.