# what is the default for DEFAULT\_GATHER\_TIMEOUT?

**URL:** <https://forum.ansible.com/t/what-is-the-default-for-default-gather-timeout/38727>\
**Category:** Ansible Project\
**Created:** [March 25, 2024, 2:54pm UTC](https://forum.ansible.com/t/what-is-the-default-for-default-gather-timeout/38727 "2024-03-25T14:54:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [March 25, 2024, 2:54pm UTC](https://forum.ansible.com/t/what-is-the-default-for-default-gather-timeout/38727/1 "2024-03-25T14:54:54Z")

</div>

Hii

While upgrading ansible we run into a deprecation warning:

[DEPRECATION WARNING]: DEFAULT\_GATHER\_TIMEOUT option, the  
module\_defaults keyword is a more generic version and can apply to all  
calls to the M(ansible.builtin.gather\_facts) or  
M(ansible.builtin.setup) actions, use module\_defaults instead. This  
feature will be removed from ansible-core in version 2.18. Deprecation  
warnings can be disabled by setting deprecation\_warnings=False in  
ansible.cfg.

This is behave we have this in ansible.cfg:

gather\_timeout = 60

I intend to use the recommended module\_defaults, but it is not clear  
to me to what exactly this setting applies. According to  
[https://docs.ansible.com/ansible/latest/reference\_appendices/config.html#default-gather-timeout:](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-gather-timeout:)

"Set the timeout in seconds for the implicit fact gathering, see the  
module documentation for specifics. It does not apply to user defined  
ansible\_collections.ansible.builtin.setup\_module tasks."

If I read this correctly, DEFAULT\_GATHER\_TIMEOUT is only for  
[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/gather\_facts\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/gather_facts_module.html)  
- right?

In any case, neither pages list a default for this.

[https://docs.ansible.com/ansible/9/collections/ansible/builtin/setup\_module.html#parameter-gather\_timeout](https://docs.ansible.com/ansible/9/collections/ansible/builtin/setup_module.html#parameter-gather_timeout)  
lists 10 seconds, but according to the line above that is something  
else altogether.

So, what is the default for DEFAULT\_GATHER\_TIMEOUT?

thx

Dick

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [March 25, 2024, 3:48pm UTC](https://forum.ansible.com/t/what-is-the-default-for-default-gather-timeout/38727/2 "2024-03-25T15:48:29Z")

</div>

Hey Dick,

This bit seems to be confusing:

> ### DEFAULT\_GATHER\_TIMEOUT[](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-gather-timeout)Description:
> 
> Set the timeout in seconds for the implicit fact gathering, see the module documentation for specifics. It does **not** apply to user defined [ansible\_collections.ansible.builtin.setup\_module](https://docs.ansible.com/ansible/9/collections/ansible/builtin/setup_module.html#ansible-collections-ansible-builtin-setup-module) tasks.

I think there’s a historical wart here. When a playbook contains “gather\_facts: true”, it calls the gather\_facts module. This in turn calls the setup module to accomplish the fact gathering. In that case _only_, and only if DEFAULT\_GATHER\_TIMEOUT is set, it will invoke the setup module with, effectively, “timeout: ‘{{ DEFAULT\_GATHER\_TIMEOUT }}’”.

The last line I quoted above means that if you, somewhere in your tasks, call the setup module, it won’t use DEFAULT\_GATHER\_TIMEOUT, and if you don’t include a “timeout:” yourself, in that case the setup module’s default of 10 seconds will be used rather than whatever value DEFAULT\_GATHER\_TIMEOUT may be set to.

`ansible-config dump` shows the default value for DEFAULT\_GATHER\_TIMEOUT is None – it’s undefined, and in fact will soon be going away. When you don’t set it, and nothing else sets the timeout for the setup module, that module uses its 10 second default.

Does that get at what you were asking?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 25, 2024, 3:51pm UTC](https://forum.ansible.com/t/what-is-the-default-for-default-gather-timeout/38727/3 "2024-03-25T15:51:59Z")

</div>

Sadly, there is not a simple answer, this setting has always been  
overloaded for 2 uses:  
- total time a 'subfact' gathering will take: system, local,  
networking, etc, though this list is never clear to the user .. or  
really in the code.  
- total time a particular fact (really only disk/device related ones)  
is allowed to take before we abandon the effort. This is mostly to  
deal with very slow or buggy network mounts (/me stares at NFS).

Also this didn't actually work for a long well in the code as the  
facts module\_utils just hardcoded it's own version with it's own  
defaults which were not always in sync.Eventually this was fixed  
(except the default being 10).

In the meantime 'gather\_facts' became an action plugin vs being  
hardcoded to be the 'setup.py' module, with some logic that makes it  
'smart', specifically for networking appliances but also user  
customizable (i use a 'mini\_setup' + service\_facts for example). So  
the timeout didn't make as much sense as it was created specifically  
thinking of 'setup.py', hence the deprecation as a config item.

In the future of 'fact gathering' we are mulling over several things,  
the main one is splitting 'setup.py' into several dozen modules and  
making 'gather\_facts' even smarter depending on OS/distro targeted. We  
also want to define more specific timeouts, like 'hardware' facts  
(which check for the devices/mounts/disks as I mentioned above) and  
'per plugin' timeouts. These will have much clearer language vs the  
now deprecated 'default\_gather\_timeout'.

I hope this helps.
