Automation · Ansible
Playbooks
Cheat sheet · https://pcornel.dk/topic.php?topic=5397
Answer
Ansible playbooks are YAML automation documents that compose one or more plays, imports/includes and execution controls into a repeatable automation entry point.
Remember
- YAML parses ≠ automation intent correct; semantic targeting and variables can still be wrong.
- Playbook success ≠ every host changed; tasks can skip and hosts can be outside selection.
- Same playbook file ≠ same outcome; inventory, vars, content versions and target state affect execution.
- Playbook in Git ≠ playbook executed; version control and runtime invocation are separate.
First checks
ansible-playbook site.yml --syntax-check— syntaxansible-playbook site.yml --list-tasks— task listansible-playbook site.yml --check --diff— preview
Commands
ansible-playbook <playbook.yml> --check --diff- Preview supported playbook changes and differences.
ansible-playbook <playbook.yml>- Run a playbook against the inventory; add --check --diff to preview changes.
Verify in this order
playbook → plays → tasks
Where it usually breaks
A playbook completing proves Ansible processed the selected content path; it does not prove every intended host was selected or every workload acceptance condition passed.
Playbooks Ansible boundary map
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Inputs / selection | Correct inventory, hosts, variables/facts and content are explicit | Wrong scope, stale facts, hidden precedence or content-version drift |
| Execution | Connection, privilege, module/task context and ordering match intent | Unreachable, wrong execution host, privilege/plugin failure or misleading skip/change state |
| Result semantics | Per-host/item results are preserved and interpreted correctly | Aggregate recap hides partial/skipped/handled failures |
| Target proof | Resource/workload read-back and rerun confirm convergence | Green Ansible status treated as end-to-end acceptance |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5397