Pcornel
Automation · Ansible

Playbooks

Cheat sheet · https://pcornel.dk/topic.php?topic=5397

Back to the Topic

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 — syntax
  • ansible-playbook site.yml --list-tasks — task list
  • ansible-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

BoundaryHealthy evidenceSuspicious evidence
Inputs / selectionCorrect inventory, hosts, variables/facts and content are explicitWrong scope, stale facts, hidden precedence or content-version drift
ExecutionConnection, privilege, module/task context and ordering match intentUnreachable, wrong execution host, privilege/plugin failure or misleading skip/change state
Result semanticsPer-host/item results are preserved and interpreted correctlyAggregate recap hides partial/skipped/handled failures
Target proofResource/workload read-back and rerun confirm convergenceGreen 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

Confirmation

Confirm action

Continue?