How do you gather only some facts to save time?
IntermediateConceptVariables, Facts and Precedence
Answer
Use gather_subset to include or exclude categories, or filter to select keys.
- hosts: all
gather_facts: true
gather_subset:
- "!hardware"
- "!all"
- network
min is always collected. Hardware facts (disks, DMI) are the slowest on big hosts. You can also run ansible.builtin.setup with gather_subset: min as a task and only gather more if needed.
More on Variables, Facts and Precedence
Where can you define variables in Ansible?BeginnerHow do you reference a variable, and when must you quote it?BeginnerGive a summary of variable precedence.IntermediateWhat are the lowest and highest precedence sources, and why does that matter?IntermediateWhat is the difference between a role's `defaults/` and `vars/`?IntermediateWhat are facts and how are they gathered?Beginner