Pcornel
Automation · Ansible

Static Inventory

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

Back to the Topic

Answer

Static inventory stores host/group declarations in versioned or locally managed inventory files rather than discovering them dynamically at runtime.

Remember

  • Static ≠ current; file-backed inventory can become stale relative to infrastructure.
  • File parses ≠ host mapping correct; syntactic validity does not validate endpoints.
  • Committed file ≠ active file; invocation/config may point to another inventory source.
  • Static inventory ≠ immutable; local edits can diverge from version control.

First checks

  • cat inventory/hosts.yml — static inventory
  • ansible-inventory -i inventory/hosts.yml --graph — parse
  • Variables in group_vars, not inline — structure

Verify in this order

file → hosts/groups

Where it usually breaks

A valid static inventory proves a deterministic file can be parsed; it does not prove the file is current or represents live infrastructure accurately.

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

Static 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=5395

Confirmation

Confirm action

Continue?