Pcornel
Automation · Ansible

Inventory

Cheat sheet · https://pcornel.dk/topic.php?topic=5394

Back to the Topic

Answer

Ansible inventory defines the addressable host/group model and can attach variables or metadata used during host selection and execution.

Remember

  • Host in inventory ≠ selected by the play; pattern/limit can exclude it.
  • Inventory hostname ≠ DNS name or IP; connection variables can redirect the endpoint.
  • Group membership ≠ authorization; it is automation metadata, not an access-control decision.
  • Inventory variable ≠ final variable value; higher-precedence sources may override it.

First checks

  • ansible-inventory -i inventory --graph — groups
  • ansible-inventory -i inventory --list — JSON
  • ansible-inventory --host <h> — host vars

Verify in this order

inventory source → hosts/groups → plays

Where it usually breaks

Inventory output proves Ansible sees a host/group model; it does not prove reachability, authorization or final variable values.

Inventory/vars → play/task selection → connection/become → module request → module result → target object read-back → handler/service effective state → workload verification.

Inventory Ansible boundary map

BoundaryHealthy evidenceSuspicious evidence
Inputs / selectionCorrect inventory, hosts, variables/facts and content are explicitWrong scope, stale facts, hidden precedence or content-version drift
ExecutionConnection, privilege, module/task context and ordering match intentUnreachable, wrong execution host, privilege/plugin failure or misleading skip/change state
Result semanticsPer-host/item results are preserved and interpreted correctlyAggregate recap hides partial/skipped/handled failures
Target proofResource/workload read-back and rerun confirm convergenceGreen Ansible status treated as end-to-end acceptance

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5394

Confirmation

Confirm action

Continue?