How do you gather only specific facts from hosts?
BeginnerProductionRapid-Fire Commands
Answer
ansible web -m ansible.builtin.setup -a "filter=ansible_distribution*"
ansible web -m ansible.builtin.setup -a "gather_subset=!all,!min,network"
ansible web -m ansible.builtin.setup --tree /tmp/facts # one JSON file per host
Handy for quick inventory audits, such as checking OS versions across a fleet before an upgrade.
More on Rapid-Fire Commands
How do you see which hosts a playbook would run against, without running it?BeginnerHow do you list the tasks and tags a playbook contains?BeginnerHow do you inspect the inventory structure and a host's variables?BeginnerHow do you restart a service on a group with an ad-hoc command?BeginnerHow do you resume a playbook from a specific task or step through it?BeginnerHow do you re-run a playbook only on the hosts that failed?Intermediate