BacklogZero®

Ansible in a Minute · Ansible Core ·

Use gather_facts false to skip fact gathering

Short answer

Set gather_facts false so Ansible does not run setup at the start of the play.

Subscribe for updates

Get an email whenever we publish new guides and blog posts. Unsubscribe anytime.

By subscribing you agree we may email you about Ansible in a Minute and related Level Up Labs updates. We store your address in the same lead sheet as our contact form.

Request

skip fact gathering and print inventory_hostname

Example

A quick heads-up: Every environment is different. Review and test this example before you run it on systems you care about.

YAML
---
- name: Skip fact gathering
  hosts: all
  gather_facts: false
  tasks:
    - name: Print inventory hostname without facts
      ansible.builtin.debug:
        msg: "{{ inventory_hostname }}"

How it works

Ansible gathers facts at the start of each play by default. gather_facts false skips that setup step. Magic variables such as inventory_hostname still exist. ansible_facts is not populated.

When to use it

  • Speeding up plays that do not need host facts
  • Targeting hosts that cannot run the setup module

Requirements

  • Ansible: >=2.14

Validation

  • Syntax validated
  • Not execution-tested
  • Last verified 2026-09-22

Notes

false and no are the same boolean. To skip facts unless a play requests them, set gathering = explicit in ansible.cfg. Use gather_subset when you need some facts, not all of them.

Reference

Built for every Ansible use case in every organization

BacklogZero can generate this kind of automation in your environment, just like it did here.

Get BacklogZero today

Related guides

Back to Ansible in a Minute

Use gather_facts false to skip fact gathering · Level Up Labs