Use it when configuring, checking or troubleshooting Plays in Ansible.
Plays
A play binds a host pattern to variables, roles/tasks, privilege and execution behavior, forming a host-scoped unit inside a playbook.
1. A play maps hosts to roles/tasks.
2. Set become, serial, strategy per play.
3. gather_facts when needed.
4. Keep plays focused.
5. Limit hosts carefully.
play → hosts → tasks
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
play host pattern/limit → play vars/become/strategy → role/task ordering → handlers → per-host recap → target state
Healthy evidence: host membership is explicit, play settings resolve as intended, ordering is understood and each participating host is verified.
Step 2 Failure modes and next checks Narrow the fault
Suspicious evidence: empty/incorrect host patterns, overridden vars, unexpected role ordering, partial failures or assuming playbook-wide status describes every host.
Step 3 Common mistakes Narrow the fault
- Several plays targeting the wrong host pattern.
gather_factson network devices that do not need it.
Step 4 Where it fails Narrow the fault
Where Plays usually goes wrong: play/host-pattern identity, task ordering, variables, handlers and per-host terminal state.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- 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.
ansible-playbook site.yml --list-hosts— hosts per play- hosts:, become:, gather_facts: per play — settings
- Play-level vars — scope
ReferenceWhat it is1 section · depth on demand
Core model
Evaluate each play by its host pattern and limit result, play-level vars/become/strategy settings, pre/tasks/roles/post ordering and handler interactions.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
A play executing shows its selected host/task graph ran under Ansible semantics, but it does not show excluded hosts or external service dependencies.
In depth
A play is one section of a playbook that applies tasks to a set of hosts with shared settings: hosts, connection, privilege escalation, variables and fact gathering. Multiple plays in a playbook run in order.
| Play keyword | Purpose |
|---|---|
hosts | Target group or pattern |
become | Privilege escalation |
gather_facts | Collect host facts first |
serial | Batch size for rolling changes |
vars / vars_files | Play variables |
pre_tasks / post_tasks | Before/after roles |
Use separate plays when different hosts need different steps in sequence, e.g. drain load balancer, patch web servers, re-enable.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Ansible > Plays. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.ansible.com/ansible/latest/ · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Plays Ansible boundary map
Fast input/selection, execution/result and target-proof boundaries for Plays.
| 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 |
Deep reference
Healthy vs suspicious evidence
Output interpretation
For Plays, rely on structured fields and stable IDs (play/host-pattern identity, task ordering, variables, handlers and per-host terminal state) rather than text formatted for display.