ansible.builtin.gather_facts module – Gathers facts about remote hosts
Note
This module is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
module name
gather_facts
even without specifying the collections keyword.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.gather_facts
for easy linking to the
module documentation and to avoid conflicting with other collections that may have
the same module name.
New in Ansible 2.8
Synopsis
This module takes care of executing the configured facts modules, the default is to use the ansible.builtin.setup module.
This module is automatically called by playbooks to gather useful variables about remote hosts that can be used in playbooks.
It can also be executed directly by
/usr/bin/ansible
to check what variables are available to a host.Ansible provides many facts about the system, automatically.
Note
This module has a corresponding action plugin.
Parameters
Parameter |
Comments |
---|---|
A toggle that controls if the fact modules are executed in parallel or serially and in order. This can guarantee the merge order of module facts at the expense of performance. By default it will be true if more than one fact module is used. For low cost/delay fact modules parallelism overhead might end up meaning the whole process takes longer. Test your specific case to see if it is a speed improvement or not. The Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Indicates this has a corresponding action plugin so some parts of the options can be executed on the controller |
|
Support: none while this action does not support the task ‘async’ keywords it can do its own parallel processing using the |
Supports being used with the |
|
Support: none |
Forces a ‘global’ task that does not execute per host, this bypasses per host templating and serial, throttle and other loop considerations Conditionals will work as if This action will not work normally outside of lockstep strategies |
|
Support: full since this action should just query the target system info it always runs in check mode |
Can run in check_mode and return changed status prediction without modifying target, if not supported the action will be skipped. |
|
Support: none |
Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
|
Support: full |
Action returns an |
|
Platforms: all The action plugin should be able to automatically select the specific platform modules automatically or can be configured manually |
Target OS/families that can be operated against |
Notes
Note
This is mostly a wrapper around other fact gathering modules.
Options passed into this action must be supported by all the underlying fact modules configured.
If using
gather_timeout
and parallel execution, it will limit the total execution time of modules that do not acceptgather_timeout
themselves.Facts returned by each module will be merged, conflicts will favor ‘last merged’. Order is not guaranteed, when doing parallel gathering on multiple modules.
Examples
# Display facts from all hosts and store them indexed by hostname at /tmp/facts.
# ansible all -m ansible.builtin.gather_facts --tree /tmp/facts