Pcornel
Automation · Ansible

Plays

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

Back to the Topic

Answer

A play binds a host pattern to variables, roles/tasks, privilege and execution behavior, forming a host-scoped unit inside a playbook.

Remember

  • Play exists ≠ host participates; host pattern plus limit determines membership.
  • Play-level variable ≠ final value; other precedence sources can override it.
  • Role listed ≠ every role task runs; tags/conditionals/includes can alter execution.
  • Play success on one host ≠ all hosts succeeded; results are host-specific.

First checks

  • ansible-playbook site.yml --list-hosts — hosts per play
  • hosts:, become:, gather_facts: per play — settings
  • Play-level vars — scope

Verify in this order

play → hosts → tasks

Where it usually breaks

A play executing proves its selected host/task graph ran under Ansible semantics; it does not prove excluded hosts or external service dependencies.

Inventory/vars → play/task selection → connection/become → module request → module result → target object read-back → handler/service effective state → workload verification.

Plays 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=5398

Confirmation

Confirm action

Continue?