'Is it possible to increase the timeout for apt_repository module?

I have this in my playbook:

- name: Add Glusterfs APT Repository
    become: yes
    become_method: sudo
    environment:
      http_proxy: http://192.168.42.250:3128/
      https_proxy: http://192.168.42.250:3128/
    apt_repository:
      repo: ppa:gluster/glusterfs-7
      state: present

But I get:

fatal: [192.168.42.105]: FAILED! => {"changed": false, "msg": "failed to fetch PPA information, error was: Request failed: <urlopen error timed out>"}
fatal: [192.168.42.103]: FAILED! => {"changed": false, "msg": "failed to fetch PPA information, error was: Request failed: <urlopen error timed out>"}
fatal: [192.168.42.102]: FAILED! => {"changed": false, "msg": "failed to fetch PPA information, error was: Request failed: <urlopen error timed out>"}
fatal: [192.168.42.104]: FAILED! => {"changed": false, "msg": "failed to fetch PPA information, error was: Request failed: <urlopen error timed out>"}
fatal: [192.168.42.107]: FAILED! => {"changed": false, "msg": "failed to fetch PPA information, error was: Request failed: <urlopen error timed out>"}
fatal: [192.168.42.101]: FAILED! => {"changed": false, "msg": "failed to fetch PPA information, error was: Request failed: <urlopen error timed out>"}
fatal: [192.168.42.106]: FAILED! => {"changed": false, "msg": "failed to fetch PPA information, error was: Request failed: <urlopen error timed out>"}

This happens because the Proxy takes a long time to respond. It is because of DNS settings applied via company group policies I cannot change.

Can I somehow increase that timeout?

Followup - Workaround

I got it to work with this workaround:

  - name: Receive Glusterfs key
    become: yes
    become_method: sudo
    environment:
      http_proxy: http://192.168.42.250:3128/
      https_proxy: http://192.168.42.250:3128/
    command: apt-key adv --keyserver keyserver.ubuntu.com --keyserver-options http-proxy=http://192.168.42.250:3128/ --recv-keys f7c73fcc930ac9f83b387a5613e01b7b3fe869a9
  - name: Add Glusterfs APT Repository
    become: yes
    become_method: sudo
    apt_repository:
      repo: deb http://ppa.launchpad.net/gluster/glusterfs-7/ubuntu xenial main
      state: present
  - name: Add Glusterfs APT Repository (source)
    become: yes
    become_method: sudo
    apt_repository:
      repo: deb-src http://ppa.launchpad.net/gluster/glusterfs-7/ubuntu xenial main
      state: present

This seems a bit like a dirty hack though. Is this the solution for my specific problem?



Solution 1:[1]

You can create apt config file like this for example:

$ cat /etc/apt/apt.conf.d/99timeouts 
Acquire::http::timeout "240";
Acquire::https::timeout "240";

to extend the connection timeout.

Solution 2:[2]

Just add until/retries/delay and at should be enough.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 IgorC
Solution 2 sorin