Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Inventory Validation

Direct answer

Inventory validation checks that hosts are reachable, names and addresses are unique, required variables are set and groups are correct before automation runs against them.

When to use this

Use this when checking inventory before running jobs.

First 30 seconds

1. Validate inventory: required variables, types, uniqueness, reachability.

2. Run in CI.

3. Fail on errors.

4. Report unreachable hosts.

5. Fix in SoT.

Operational verification

inventory → validation → report

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. · Ansible
Key commandansible-inventory --list
Scope / prerequisiteUse this when checking inventory before running jobs.
Reference · 1
What next?3 suggested next steps
Catalog command links1
Evidence0
On this pageJump to a specific section
Automation command reference

Primary Commands

Configuration and operational commands for this Topic.

Operational workflow

Verification & Troubleshooting

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

5 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 Known-good, broken and when it is fixed Verify boundary

Known-good requires deterministic resolution of the intended target set, no unexpected duplicates, required variables present with expected types/values and a bounded dry-run/read-only query reaching the same objects. Passing syntax validation shows format only; resolved inventory identity and target reachability close the pre-execution boundary.

Step 2 Command read-back and what it shows Verify boundary

ansible-inventory --list is the bounded verification surface selected for Inventory → Inventory Validation. A known-good result is each expected target resolves once with the intended groups, connection identity and critical variables, and a bounded downstream connectivity/read-only task reaches the same target. Treat targets are missing/duplicated, unexpected groups or hostvars win precedence, stale plugin data is present, or downstream execution reaches a different endpoint as broken/suspicious. ansible-inventory --list shows controller-side resolved inventory at execution time, but it does not show network reachability, credentials or managed-node convergence.

Step 3 Common mistakes Narrow the fault
  • Inventory without validation of required fields.
Step 4 Native failure isolation and next-check logic Narrow the fault

Resolve the exact inventory as the automation engine sees it and compare target count, identities, groups and critical variables with the authoritative source. If hosts are missing or duplicated, inspect discovery/filtering and normalization. If the target set is correct but variables are wrong, trace precedence/merge order and environment-specific overrides before editing task logic.

Step 5 Observation-driven branch and next-check logic Narrow the fault

For a failing Inventory → Inventory Validation case, freeze scope first: target/object, desired revision or request, and failure time. Inspect ansible-inventory --list. Branch on evidence rather than labels: if the target is absent or duplicated, inspect source filters and identity keys; if membership is correct but variables resolve unexpectedly, inspect group/host precedence and plugin data; if inventory is correct but execution fails, move to transport/authentication/target state.

Key points
  • Check reachability before running jobs.
  • Names and addresses must be unique.
  • Required variables must be set.
Key checks
  • Inventory validation script (required vars, reachability) — checks
  • ansible all -m ping — reachability
  • Schema check of host vars — types
ReferenceHow it works3 sections · depth on demand

How it works

How it works: Ansible resolves inventory/group/host variables, renders task/module arguments, establishes the connection/become context, executes modules on the selected target and reports changed/ok/failed.

How it works

Inventory validation checks that automation targets, groups, variables and identifiers are complete, unique and internally consistent before execution. Static/dynamic inventory can be syntactically valid while resolving to the wrong hosts or stale attributes. The resolved execution set is the operational object; source file/API success alone is not enough.

How it works

In Inventory → Inventory Validation, effective state is split across inventory source parsing, host/group membership, variable precedence and the resolved endpoint identity passed to later automation stages. Dynamic and static inventory plugins produce a resolved graph of hosts, groups and hostvars; later playbooks consume this graph, so validation must check identity and precedence rather than only parser success. Plugin credentials, source API freshness, DNS, duplicate identifiers and secrets outside inventory are separate things to check. This matters because valid JSON/YAML inventory can still omit a target or assign the wrong connection variables, while a host present in inventory can still be unreachable.

ReferenceImportant terms & boundaries1 section · depth on demand

Method

Inventory validation checks the automation inventory before jobs run, so automation never targets wrong, missing or decommissioned systems.

1. Validate structure: every host has required variables (IP, platform, site, role).

2. Validate values: IP format, platform in the supported list, unique names and IPs.

3. Compare with the source of truth: no hosts missing, none extra.

4. Test reachability for a sample or all hosts.

5. Fail the pipeline on errors; report warnings.

ansible-inventory -i inventory/ --list > inv.json
python validate_inventory.py inv.json --schema schemas/host.json
CheckCatches
Duplicate IPsCopy-paste mistakes
Status = decommissionedJobs against retired devices
Unknown platformWrong driver selection
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 > Inventory Validation. 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%
Confirmation

Confirm action

Continue?