gather_timeout in ansible.cfg DEPRECATED

Hi,

I have this in our ansible.cfg:

[defaults]
gather_timeout = 60

With ansible 7, I get:

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

It seems that the equivalent of that single line in ansble.cfg, is that add this to every play in our playbook:

module_defaults:
ansible.builtin.setup:
gather_timeout: 60
ansible.builtin.gather_facts:
gather_timeout: 60

We have many plays, which means a lot of extra (duplicated) code.
Is there a way to set this more centrally?
Or am I missing something entirely :slight_smile:

thx!

Dick

In a play it looks like you can just add gather_timeout: 60 still so that is less to add but your findings are spot on otherwise.

  • name: ‘A playbook’
    hosts: printservers
    gather_timeout: 60
    tasks:
  • name: ‘Do something’
    ansible.builtin.debug:
    var: ansible_play_hosts_all