Use this when grouping nodes for configuration management.
Inventory · Configuration Management
Inventory in configuration management lists the managed nodes and groups them by role, environment or location, with variables that tailor the configuration each node receives.
1. Inventory defines managed hosts and groups.
2. Dynamic from source of truth/cloud.
3. Groups by role/site/env.
4. Validate inventory.
5. Remove decommissioned hosts.
source → inventory → targets
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 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as inventory drift, variable precedence surprises, template rendering errors, non-idempotent modules, partial convergence and green task status with unhealthy service, choosing the cases most relevant to authoritative object selection, revision/freshness, relationship traversal and preventing automation from using stale or duplicate inventory records.
Step 2 Common mistakes Narrow the fault
- Stale static inventories.
- The same host in groups with conflicting variables.
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.
- Inventory groups nodes by role, environment and location.
- Group variables tailor configuration.
- Generate inventory from a source of truth where possible.
ansible-inventory --graph— structureansible-inventory --list | jq '._meta.hostvars | keys | length'— hosts- Dynamic source — accuracy
ReferenceWhy it matters1 section · depth on demand
What it is
The inventory lists the managed hosts and groups and their variables. It can be static files or generated dynamically from NetBox, cloud APIs or a CMDB.
ReferenceImportant terms & boundaries2 sections · depth on demand
Example
ansible-inventory -i inventory/ --graph
ansible-inventory -i inventory/ --host sw01
In depth
Inventory in configuration management defines which systems a configuration applies to and with which variables. It connects the "what" (roles, templates) with the "where" (hosts and groups).
Good structure:
- Group by function (role), location (site) and environment, and combine groups to target.
- Keep group and host variables in files next to the inventory (
group_vars/,host_vars/). - Separate inventories per environment so a run against test cannot reach production.
inventories/
prod/
hosts.yml
group_vars/all.yml
group_vars/role_access.yml
test/
hosts.yml
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 Configuration Management > Inventory. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_intro.html · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For authoritative object selection, revision/freshness, relationship traversal and preventing automation from using stale or duplicate inventory records, prefer typed fields and stable IDs over human presentation text.