Quiz Entry - updated: 2026.11.05
Why and how would you turn off fact gathering for a play?
Set gather_facts: false on the play. Do it when the play doesn't use facts (to save time and load on the hosts), or when the hosts can't run setup yet, for example because Python or other software must be installed first. You can still gather facts later with a setup task.
- name: Bootstrap new hosts
hosts: new_servers
gather_facts: false
tasks:
- name: Install Python so modules can run
ansible.builtin.raw: apt-get install -y python3
- name: Gather facts now that Python is there
ansible.builtin.setup:
Fact gathering is a full extra round trip per host at the start of every play. On a few hosts that hardly matters, but on hundreds of hosts, or in a playbook with many short plays, it adds up. And on a freshly installed or minimal host, setup may fail, which would stop the play before your first task runs.
Go deeper:
Disabling facts (official docs) —
gather_facts: false.Fact caching (official docs) — the other way to avoid gathering on every run.