0Pricing
Ansible Academy · Lesson

What Facts Are & Why They Matter

Auto-discovered data about each host.

What Facts Are & Why They Matter is a free Ansible Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ansible Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Servers Know Themselves

Every server already holds tons of detail: its OS, memory, IP and more. Ansible can read all of it automatically before doing any work. 🌟

Meet Facts

Ansible calls this auto-discovered system data facts. They describe each host so your playbook can adapt to the machine it runs on.

Gathered Automatically

By default, every play runs a hidden Gathering Facts step first. It collects facts before your real tasks even start.

PLAY [web] *****
TASK [Gathering Facts] *****
ok: [host1]

Stored as Variables

Each fact becomes a regular variable you can read. They live under the ansible_facts dictionary for the current host.

ansible_facts['distribution']
ansible_facts['memtotal_mb']

What Facts Cover

Facts include the OS family, hostname, network addresses, CPU count, mounted disks and much more. It is a full profile of the host.

Why They Matter

Facts let one playbook work on many different machines. You can branch on the real OS instead of guessing or hardcoding values.

A Quick Example

Want to print a host's OS? Reference its distribution fact in a debug task and Ansible fills in the real value per host.

- debug:
    var: ansible_facts['distribution']

Per-Host Values

Facts are gathered per host, so the same variable holds different values on each machine. One play, many tailored results.

The Old ansible_ Names

You will often see facts as top-level vars like ansible_distribution. These are the same facts exposed without the dictionary prefix.

{{ ansible_distribution }}
{{ ansible_memtotal_mb }}

Facts Cost a Little Time

Gathering facts connects and probes each host, which takes a moment. It is usually worth it, but you can skip it when unneeded.

Smarter Automation

With facts, your playbooks become adaptive: install the right package, use the right path, or act only on hosts that match.

Quick Check

What exactly are Ansible facts?

Recap

You learned that facts are auto-gathered host data, stored in ansible_facts, that let one playbook adapt to many machines. ✨

Frequently asked questions

Is the “What Facts Are & Why They Matter” lesson free?

Yes — the full text of “What Facts Are & Why They Matter” is free to read here on the web, and the Ansible Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ansible Academy course, upgrade to CoddyKit PRO.

What will I learn in “What Facts Are & Why They Matter”?

Auto-discovered data about each host. You practise Ansible Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Ansible Academy?

No prior experience is required. Ansible Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “What Facts Are & Why They Matter” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Ansible Academy lesson?

Yes. Every Ansible Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Facts Are & Why They Matter
  2. Explore Facts with the setup Module
  3. Use ansible_facts in Tasks
  4. Disabling Fact Gathering for Speed
← Back to Ansible Academy