CertGrid CertGrid
Hands-on Lab·Ansible

Ansible Facts and Gathering Overhead

Facts are what a managed node knows about itself, and Ansible collects them before every play unless told not to. That is a real cost, measured here at more than three times the runtime of a play that skips it. This covers what a fact is, the handful you will use, what turning gathering off breaks, and how to publish your own facts from a file on the host.

Plays and Playbooks Guide 12 of 45 Intermediate

Written against the versions above. Facts are being renamed. Running a play that uses `ansible_hostname` now prints a deprecation warning: top-level fact injection is going away in ansible-core 2.24, and the supported form is `ansible_facts['hostname']` - the same value without the `ansible_` prefix, inside the `ansible_facts` dictionary. New playbooks should use the dictionary form.

Both managed nodes, because the gathering cost is per host and the timing only means something with more than one.
Server NameIP AddressOSRolesCPURAMHDD
ANS-CTL01192.168.0.36Ubuntu 26.04 LTSAnsible Control Node2 Core3 GB50 GB
ANS-A01192.168.0.37Ubuntu 26.04 LTSManaged Node (group: web)2 Core3 GB50 GB
ANS-B01192.168.0.38Ubuntu 26.04 LTSManaged Node (group: db)2 Core3 GB50 GB

Before you start

  1. The configuration this guide assumes

  2. What a fact is

  3. The ones you will actually use

  4. What gathering costs

  5. Without facts, the variables are gone

  6. Your own facts

Official sources