Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Facts

Direct 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.

When to use this

Use it when configuring, checking or troubleshooting Facts in Ansible.

First 30 seconds

1. Facts are gathered system information.

2. gather_facts: false when not needed.

3. Cache facts for speed.

4. Custom facts in /etc/ansible/facts.d.

5. Use ansible_facts namespace.

Operational verification

setup module → facts → variables

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Ansible automation
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.

PlatformAnsible automation · Facts owns Ansible host observation data. Deep hardware/OS/application telemetry remains in target domains.
Scope / prerequisiteUse it when configuring, checking or troubleshooting Facts in Ansible.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

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

3 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 Operational evidence path Verify boundary

target observation → fact plugin/gathering → cache/hostvars → conditional/template/task use → target action

Healthy evidence: fact source/time and host context are explicit, cache semantics are known and critical values are corroborated when required.

Step 2 Failure modes and next checks Narrow the fault

Suspicious evidence: stale cache, disabled gathering assumptions, custom-fact drift, cross-platform key mismatch or treating facts as timeless truth.

Step 3 Common mistakes Narrow the fault
  • Gathering facts when not needed (slow).
  • Stale cached facts.
Evidence references

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.

observation · 1
Key points
  • 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.
Key checks
  • ansible <h> -m setup — all facts
  • ansible <h> -m setup -a 'filter=ansible_default_ipv4' — filtered
  • Fact caching (jsonfile/redis) — performance
ReferenceWhat it is1 section · depth on demand

Core model

Establish whether gathering occurred, which subset/plugin produced the fact, cache age/source and the exact host context before using a fact as current-state evidence.

ReferenceImportant terms & boundaries2 sections · depth on demand

What this shows and what it does not

A fact shows what its collection path reported for a host at a point in time; it does not guarantee freshness or complete target truth.

Deep hardware/OS/application telemetry remains in target domains.

In depth

Facts are information Ansible gathers about managed hosts — OS, interfaces, IP addresses, memory, software versions — and makes available as variables. For servers they come from the setup module; for network devices from platform fact modules.

- hosts: switches
  gather_facts: false
  tasks:
    - cisco.ios.ios_facts:
        gather_subset: [min]
        gather_network_resources: [vlans, interfaces]
    - debug:
        msg: "{{ ansible_net_hostname }} runs {{ ansible_net_version }}"
ansible web01 -m ansible.builtin.setup -a 'filter=ansible_default_ipv4'

Gathering facts takes time; disable it where not needed and gather only the subsets you use. Fact caching (fact_caching = jsonfile or redis) speeds up repeated runs.

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 docAnsible automation current

Authoritative/upstream documentation reviewed for bounded claims in Ansible > Facts. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://docs.ansible.com/ansible/latest/ · confidence 94%
Terminology layer

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.

Aliases that resolve here
ansible factsgather factshostvars factsfact cache
Embedded reference data

Quick lookup tables

Facts Ansible boundary map

Fast input/selection, execution/result and target-proof boundaries for Facts.

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
Confirmation

Confirm action

Continue?