What Facts Are & Why They Matter
Auto-discovered data about each host.
What Facts Are & Why They Matter is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 1 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.
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. ✨
Learn DevOps Bootcamp with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 142
- Lessons
- 568
Frequently Asked Questions
Is the “What Facts Are & Why They Matter” lesson free?
Yes — any 3 lessons of the DevOps Bootcamp learning path, including “What Facts Are & Why They Matter”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.
What will I learn in “What Facts Are & Why They Matter”?
Auto-discovered data about each host. You practise DevOps Bootcamp 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 DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 1 of 4.
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 DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp 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
- What Facts Are & Why They Matter
- Explore Facts with the setup Module
- Use ansible_facts in Tasks
- Disabling Fact Gathering for Speed