# DEFAULT\_GATHER\_TIMEOUT deprecated - alternatives?

**URL:** <https://forum.ansible.com/t/default-gather-timeout-deprecated-alternatives/4028>\
**Category:** Get Help\
**Tags:** config, playbook\
**Created:** [February 23, 2024, 7:38pm UTC](https://forum.ansible.com/t/default-gather-timeout-deprecated-alternatives/4028 "2024-02-23T19:38:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![parkerfath](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/parkerfath/32/1578_2.png) [@parkerfath](https://forum.ansible.com/u/parkerfath)\
**Post date:** [February 23, 2024, 7:38pm UTC](https://forum.ansible.com/t/default-gather-timeout-deprecated-alternatives/4028/1 "2024-02-23T19:38:50Z")

</div>

I’m seeing this message on running my playbooks:

* * *

[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.

* * *

I’d like to “do things the right way” and prepare for new Ansible versions, but I’m struggling to decide how to update my config/playbooks. It seems like using module\_defaults requires updating all of my playbooks, whereas I can set gather\_timeout in [defaults] on my ansible.cfg. We use this, for example, to swap in a “slow config” when deploying to systems with slow network connections. I don’t want to have to build a “slow config” version of each of my dozens of playbooks.

I see there was some discussion in the Google Group at [https://groups.google.com/g/ansible-project/c/ZgVmYkuHj5M?pli=1](https://groups.google.com/g/ansible-project/c/ZgVmYkuHj5M?pli=1) but it didn’t really go anywhere.

---

<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:** [July 21, 2024, 6:46pm UTC](https://forum.ansible.com/t/default-gather-timeout-deprecated-alternatives/4028/2 "2024-07-21T18:46:48Z")

</div>

You do have to update all your playbooks, but if you plan ahead, you won’t have to make a “slow config” version of each of your playbooks. The following scheme seems to work, although I have done extremely limited testing:

```yaml
---
# gather-test.yml
- name: Experiment with gather_timeout
  hosts: all
  module_defaults:
    ansible.builtin.setup:
      gather_timeout: '{{ gather_timeout | default(10) }}'
  tasks:
    - name: Show each host's gather_timeout
      ansible.builtin.debug:
        msg: '{{ gather_timeout | default("(defaulted to 10)") }}'

```

Now you can set a “`gather_timeout`” variable in your `group_vars`, `host_vars`, or your inventory for hosts or groups that need a value other than the default.

Doing that removes your need to “swap in a ‘slow config’” `ansible.cfg` for those hosts. They should just do the Right Thing from then on.

If you _really_ plan ahead — and I’m kicking myself for not thinking of this before I modified all of our playbooks — you can create another playbook that uses `ansible.builtin.blockinfile` to maintain your “global” `module_defaults` (not necessarily limited to `ansible.builtin.setup` either) across all your playbooks. That way you’re prepared the next time a change in Ansible or your own policies or whatever necessitates such sweeping changes.

---

<div class="post-metadata">

**Author:** ![parkerfath](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/parkerfath/32/1578_2.png) [@parkerfath](https://forum.ansible.com/u/parkerfath)\
**Post date:** [July 23, 2024, 9:44pm UTC](https://forum.ansible.com/t/default-gather-timeout-deprecated-alternatives/4028/3 "2024-07-23T21:44:46Z")

</div>

Thanks! Still a shame to need to update playbooks, but it’s good to at least have a somewhat clean way to do it, and not need to create duplicate copies of all the playbooks.

---

<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:** [July 23, 2024, 9:52pm UTC](https://forum.ansible.com/t/default-gather-timeout-deprecated-alternatives/4028/4 "2024-07-23T21:52:25Z")

</div>

Kind of a meta-comment: What I’m really curious about is why your post from February 23 would be popping up in my feed in mid-July. I’m glad it did, because it gave me the incentive to do the experiment I’m been putting of for a long time now, so I have a way forward I’m more comfortable with. Still, why _now_?
