Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Groups

Direct answer

Inventory groups organize hosts by role, environment, site or platform, such as webservers or prod, so automation targets and variables apply to many hosts at once.

When to use this

Use this when grouping hosts for targeting.

First 30 seconds

1. Groups organise hosts for targeting and variables.

2. Multiple dimensions (site, role, env).

3. Avoid deep nesting complexity.

4. Use keyed_groups from SoT.

5. Document.

Operational verification

hosts → groups → plays/vars

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
automation inventory
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.

Platformautomation inventory · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when grouping hosts for targeting.
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.

2 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 Verification path Verify boundary

The negative fixture should deliberately exercise risks such as duplicate labels, stale inventory, conflicting authority, broad filters, race between read and write, orphaned relationships and automation acting on data not yet reconciled, choosing the cases most relevant to inventory grouping, group hierarchy, variable precedence and host membership identity instead of display-name assumptions.

Step 2 Common mistakes Narrow the fault
  • Overlapping groups with conflicting variables.
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
  • Groups organize hosts by role, environment or site.
  • Groups can be nested.
  • Group variables apply to all members.
Key checks
  • ansible-inventory --graph — group tree
  • Groups by role, site, environment — dimensions
  • Nested groups — hierarchy
ReferenceWhy it matters1 section · depth on demand

What it is

Groups combine hosts by role, site or platform so playbooks and variables can target them.

ReferenceImportant terms & boundaries1 section · depth on demand

In depth

Groups collect hosts that share properties — site, role, platform, environment — so automation can target them together and assign shared variables. Hosts can be in several groups, and groups can contain other groups.

all:
  children:
    site_oslo: { hosts: { sw-oslo-07: {}, rtr-oslo-01: {} } }
    role_access: { hosts: { sw-oslo-07: {} } }
    platform_ios: { children: { role_access: {} } }
ansible-playbook vlans.yml --limit 'site_oslo:&role_access'      # intersection
ansible-playbook vlans.yml --limit 'role_access:!site_lab'       # exclusion

When a variable is defined in several groups, precedence follows group depth and name order, which surprises people — keep each variable defined at one level where possible.

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 docautomation inventory current

Authoritative/upstream documentation reviewed for bounded claims in Inventory > Groups. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html · confidence 94%
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

For inventory grouping, group hierarchy, variable precedence and host membership identity instead of display-name assumptions, prefer typed fields and stable IDs over human presentation text.

Confirmation

Confirm action

Continue?