0Pricing
Ansible Academy · Lesson

Explore Facts with the setup Module

Dump and browse a host's fact tree.

Explore Facts with the setup Module is a free Ansible Academy lesson on CoddyKit — lesson 2 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.

The Fact Collector

The hidden Gathering Facts step is really one module doing the work: the setup module. You can call it yourself to explore. 🌟

Run setup Ad-Hoc

Point an ad-hoc command at a host with -m setup to dump its full fact tree right to your terminal.

ansible host1 -m setup

It Returns JSON

The output is a big JSON object under ansible_facts. Every key is a fact you can later use inside a playbook.

"ansible_facts": {
  "distribution": "Ubuntu"
}

That Is a Lot

A full dump can be hundreds of lines. To find what you need, you can filter facts instead of scrolling through everything.

Filter by Pattern

The setup module takes a filter argument. Pass a glob and it returns only the matching fact keys.

ansible host1 -m setup -a "filter=ansible_distribution*"

Common Facts to Find

Useful keys include ansible_distribution, ansible_os_family, ansible_memtotal_mb and ansible_default_ipv4 for networking.

Nested Network Facts

Some facts are nested. The host's main IP lives inside ansible_default_ipv4 under an address key you drill into.

ansible_default_ipv4:
  address: 10.0.0.5

setup Inside a Playbook

You can also list setup as a task to re-gather facts mid-play, useful after you change something on the host.

- name: Refresh facts
  ansible.builtin.setup:

Limit What It Gathers

The gather_subset option narrows collection, like only network facts, so setup runs faster when you need just a slice.

- ansible.builtin.setup:
    gather_subset:
      - network

Explore Before You Build

Running setup first is a great habit. See the real fact names on your host, then reference them confidently in tasks.

Read-Only and Safe

The setup module only reads information; it changes nothing on the host. Run it as often as you like to investigate.

Quick Check

How do you dump a single host's facts to your screen?

Recap

You used the setup module to dump and filter facts, learning the real key names before relying on them in playbooks. ✨

Frequently asked questions

Is the “Explore Facts with the setup Module” lesson free?

Yes — the full text of “Explore Facts with the setup Module” 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 “Explore Facts with the setup Module”?

Dump and browse a host's fact tree. 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 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Explore Facts with the setup Module” 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