0Pricing
Ansible Academy · Lesson

Use ansible_facts in Tasks

Branch on OS, memory and IP facts.

From Data to Decisions

Gathered facts are only useful if you act on them. Now you will pull values from ansible_facts straight into your tasks. 🌟

Reference a Fact

Use the same {{ }} syntax as any variable. Inside the braces, name the fact you want, like the host's distribution.

- debug:
    msg: "OS is {{ ansible_distribution }}"

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