Anatomy of an Ansible Playbook
August 10, 2026 · DevTools
An Ansible playbook is a list of plays; each play targets a group of hosts, optionally becomes root, declares vars, and runs a list of tasks. The playbook is YAML, which means indentation is everything — misaligned arguments fail to parse before they ever reach a server.
Each task has a human name and a module call. Modules are idempotent building blocks: apt installs packages, service controls daemons, copy ships files, git checks out repos, and command runs anything else. You pass a module its arguments as a nested map, so installing nginx is apt: with name: nginx and state: present, and starting it is service: with name: nginx, state: started, and enabled: true. Because tasks are idempotent, running the playbook twice leaves the system in the same state as once — that predictability is what makes playbooks safe to re-run.