akm9018
akm9018

Reputation: 61

ansible-playbook Timer expired after 10 seconds only on some nodes but works just fine on others

I am able to ping all the servers but when I run the playbook on all the nodes it works only on some nodes and on others I get

TimeoutError: Timer expired after 10 seconds

It was working fine. It is happening from past 1 week .

Nothing has changed wrt playbook or the ansible cfg files.

    The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_Kh_sLm/ansible_modlib.zip/ansible/module_utils/basic.py", line 2853, in run_command
    cmd = subprocess.Popen(args, **kwargs)
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1308, in _execute_child
    data = _eintr_retry_call(os.read, errpipe_read, 1048576)
  File "/usr/lib64/python2.7/subprocess.py", line 478, in _eintr_retry_call
    return func(*args)
  File "/tmp/ansible_Kh_sLm/ansible_modlib.zip/ansible/module_utils/facts/timeout.py", line 37, in _handle_timeout
    raise TimeoutError(msg)
TimeoutError: Timer expired after 10 seconds

fatal: [hostname]: FAILED! => {
    "changed": false, 
    "cmd": "/bin/findmnt --list --noheadings --notruncate", 
    "invocation": {
        "module_args": {
            "fact_path": "/etc/ansible/facts.d", 
            "filter": "*", 
            "gather_subset": [
                "all"
            ], 
            "gather_timeout": 10
        }
    }, 
    "msg": "Timer expired after 10 seconds", 
    "rc": 257
}

Upvotes: 1

Views: 5071

Answers (4)

Brook
Brook

Reputation: 159

set gather_subset=!hardware in ansible.cfg, it worked for me

Upvotes: 0

sudhir tataraju
sudhir tataraju

Reputation: 1379

Setting gather_timeout=20 in ansible.cfg should fix. source of the solution : https://github.com/ansible/ansible/issues/43884

Upvotes: 2

akm9018
akm9018

Reputation: 61

This work-around helped me. In /etc/ansible/ansible.cfg I set gather_subset = !all which basically only gathers minimum facts. I think while gathering facts something is messed up. So based on your requirement set the value to only gather those facts which is required for you.

Upvotes: 4

vishnu narayanan
vishnu narayanan

Reputation: 3933

This does not seem to be an issue with the playbooks. As @MatthewLDaniel has mentioned, try accessing the nodes that are failing via ssh. These nodes/instances might be unreachable/unresponsive over the network due to a variety of reasons. Start with checking out the instance metrics viz cpu, memory, disk and network connectivity.

PS: Restarting the instance via AWS/GCP console usually resolves ssh timeouts issue if its a system level one.

On another note, Ansible playbooks have a default timeout of 10 seconds. You could override this by passing the timeout parameter while running the playbook.

ansible-playbook playbook.yml -T <TIMEOUT>

OR

ansible-playbook playbook.yml --timeout <TIMEOUT>

Upvotes: 1

Related Questions