Facts
Cheat sheet · https://pcornel.dk/topic.php?topic=5404
Answer
Ansible facts are discovered or supplied host data used by automation logic; gathered facts represent observations at a point in time and may be disabled, cached, stale or extended by custom facts.
Remember
- Fact present ≠ fact current; cached facts can outlive target changes.
- gather_facts disabled ≠ facts unavailable necessarily; cached/custom/set facts may still exist.
- Fact value ≠ authoritative business truth; it reflects the collection method and scope.
- Same fact key across platforms ≠ identical semantics.
First checks
ansible <h> -m setup— all factsansible <h> -m setup -a 'filter=ansible_default_ipv4'— filtered- Fact caching (jsonfile/redis) — performance
Verify in this order
setup module → facts → variables
Where it usually breaks
A fact proves what its collection path reported for a host at a point in time; it does not guarantee freshness or complete target truth.
Inventory/vars → play/task selection → connection/become → module request → module result → target object read-back → handler/service effective state → workload verification.
Facts Ansible boundary map
| 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 |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5404