Use it when configuring, checking or troubleshooting Dynamic Inventory in Ansible.
Dynamic Inventory · Ansible
Dynamic inventory derives hosts, groups and variables from a plugin, script or external system at runtime instead of relying only on a fixed host file.
1. Dynamic inventory pulls hosts from NetBox, cloud APIs, vCenter, etc.
2. Plugins with YAML config.
3. Group by tags/attributes (keyed_groups).
4. Cache for speed.
5. Credentials via env/vault.
source API → inventory plugin → groups/hostvars
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
external source/API → auth/query/filter → plugin/cache → host/group composition → Ansible selection → target connection
Healthy evidence: source/query and cache semantics are known, returned host/group data matches expected scope, and representative target mapping is correct.
Step 2 Failure modes and next checks Narrow the fault
Suspicious evidence: stale cache, insufficient API permissions, hidden filters/pagination, changed naming composition or assuming discovery equals reachability.
Step 3 Common mistakes Narrow the fault
- Slow dynamic inventory without caching.
- Group names from tags that change unexpectedly.
Step 4 Where it fails Narrow the fault
Where Dynamic Inventory usually goes wrong: source authority, host/object identity, grouping/selection, staleness and downstream target resolution; provider/query identity, cache/staleness, stable host IDs and reproducible selection.
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.
- Dynamic ≠ real-time automatically; plugins can cache data or query eventually consistent APIs.
- API success ≠ complete inventory; filters, permissions and pagination can omit resources.
- Source object ≠ Ansible hostname directly; composition/keying can transform identity.
- Inventory refresh ≠ target reachable; discovery and execution are separate boundaries.
ansible-inventory -i netbox.yml --graph— NetBox pluginansible-inventory -i aws_ec2.yml --list— cloud pluginansible-doc -t inventory -l— available plugins
ReferenceWhat it is1 section · depth on demand
Core model
Trace source credentials/query, plugin configuration, returned data, cache behavior and transformation into Ansible hosts/groups before evaluating selection or connectivity.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
Dynamic inventory shows the configured discovery path returned a host model, but it does not show source completeness, freshness or target reachability.
External API/CMDB/cloud source correctness remains with those systems.
In depth
A dynamic inventory builds the host list at runtime from an external source — NetBox, VMware, Proxmox, AWS, Azure — using an inventory plugin. Hosts, groups and variables then always match the source of truth.
# inventory/netbox.yml
plugin: netbox.netbox.nb_inventory
api_endpoint: https://netbox.example.com
group_by: [sites, device_roles, platforms]
query_filters:
- status: active
export NETBOX_TOKEN=...
ansible-inventory -i inventory/netbox.yml --graph
Cache results for large sources (cache: true) and check the generated groups after source data changes.
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 > Dynamic Inventory. 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
Dynamic Inventory Ansible boundary map
Fast input/selection, execution/result and target-proof boundaries for Dynamic Inventory.
| 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 Dynamic Inventory, rely on structured fields and stable IDs (source authority, host/object identity, grouping/selection, staleness and downstream target resolution; provider/query identity, cache/staleness, stable host IDs and reproducible selection) rather than text formatted for display.