Interview Prep/Ansible/Variables, Facts and Templates

Gathering facts takes minutes on 500 hosts and you only need the OS family.

IntermediateScenarioVariables, Facts and Templates
Answer

Situation read → Fact gathering is overkill.

What I'd do →

- hosts: all
  gather_facts: false
  tasks:
    - ansible.builtin.setup:
        gather_subset: [min]
        filter: ansible_os_family

Or set gather_subset = min in ansible.cfg, and enable fact caching.

Why → The full subset runs hardware and network probes you rarely need.

Interview tip → gather_facts: false on plays that never use facts is free speed.

All Ansible questions Roadmap: Ansible

More on Variables, Facts and Templates