Concept and mechanism
Inventory connects logical names to systems automation can manage. A host may belong to several groups by function, environment, or location without becoming several independent machines. The play pattern selects a set from that inventory; intersection differs from union. To act only on application servers belonging to staging, use a selection expressing both conditions. Confirm supplied inventory, aliases, and limits before changing systems. An address configured in ansible_host does not necessarily replace the alias used for selection. The effective host list is more useful evidence than the intent written in the job name.
Guided application
In a fictional APS scenario, a pipeline is named staging but also receives production inventory. The team should inspect selection before execution and correct the source of scope. Apply the same discipline to variables: a -u option does not automatically override ansible_user from a higher-precedence source; extra vars can override other variables. Record value provenance without disclosing secrets. Distinguish Ansible community, ansible-core, and collections because their versions are not interchangeable. Inspected documentation identifies community 14 and core 2.21; that does not establish the executor version. Also confirm plugins, Python, and modules required by the target.
app:&staging selects the intersection; app:staging includes members of either group.
Common pitfalls
Job name as scope evidence; IP as a universal alias; collection version as core version.
Related topics: Tasks and desired state · Validation and handlers · Batch orchestration
Before changing systems, confirm selection, variable provenance, and executor compatibility.
Reference: How to build your inventory · Ansible community 14 / ansible-core 2.21 documentation consulted 2026-09-30; executor, collection and plugin compatibility requires confirmation