Quiz Entry - updated: 2026.10.22
Why is it a mistake to treat Ansible like a scripting language?
Ansible is a desired-state engine: you describe what the end state should be, and modules make only the necessary changes. Writing step-by-step commands throws away idempotency and readability.
| Imperative (script) | Declarative (Ansible) | |
|---|---|---|
| You write | How: run this command, then that one | What: package X present, service Y started |
| Running it twice | May repeat actions, append duplicates, fail | Changes nothing if already correct |
| Reading it | You have to simulate the steps in your head | The file states the target state directly |
A playbook full of shell: tasks is really a shell script in YAML form: it runs every command each time, reports "changed" constantly, and hides the intended end state. Use modules that express state (package, service, template, file) and Ansible works as designed.
Go deeper:
Good Practices for Ansible (Red Hat Communities of Practice) — why declarative beats imperative in playbooks, with concrete do/don't examples.
Declarative programming (Wikipedia) — the general "what, not how" paradigm compared with imperative code.