Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Plays

Direct answer

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

When to use this

Use it when configuring, checking or troubleshooting Plays in Ansible.

First 30 seconds

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.

Operational verification

play → hosts → tasks

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Ansible automation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformAnsible automation · Plays owns host-scoped orchestration inside playbooks. Individual task/module semantics live in their own Ansible Topics.
Scope / prerequisiteUse it when configuring, checking or troubleshooting Plays in Ansible.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

4 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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_facts on 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 references

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.

observation · 1
Key points
  • 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.
Key checks
  • 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 keywordPurpose
hostsTarget group or pattern
becomePrivilege escalation
gather_factsCollect host facts first
serialBatch size for rolling changes
vars / vars_filesPlay variables
pre_tasks / post_tasksBefore/after roles

Use separate plays when different hosts need different steps in sequence, e.g. drain load balancer, patch web servers, re-enable.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docAnsible automation current

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%
Terminology layer

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.

Aliases that resolve here
ansible playplay host patternplay tasksplaybook play
Embedded reference data

Quick lookup tables

Plays Ansible boundary map

Fast input/selection, execution/result and target-proof boundaries for Plays.

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
Depth when you need it

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.

Confirmation

Confirm action

Continue?