Timeout problem with far distance host

This has been discussed at many places but this scenario is certainly different. Within my repository I do have one host which is on mainland China, i.e. inside the great firewall. And therefore the connection is significantly slower than anything else. My playbooks do work most of the time, but often I do get this Timeout (12s) waiting for privilege escalation prompt: error - only on that host and although it is a real mirror of all the others.

I’m pretty sure this is a problem because of the connection delay and wonder if I can change the timeout just for that host.

You could set ConnectTimeout in ansible_ssh_args for that host

Here is what I've added to the host vars for that particular host:

Can you show -vvvv output?

That’s strange, it doesn’t use those settings although they are in the inventory for that host:

`
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/system/setup.py
ESTABLISH SSH CONNECTION FOR USER: jurgenhaas
SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=jurgenhaas -o ConnectTimeout=10 -o ControlPath=/home/jurgenhaas/.ansible/cp/ansible-ssh-%h-%p-%r fimfcn1 ‘/bin/sh -c ‘"’“‘sudo -H -S -p “[sudo via ansible, key=rczwjukcmjelutvbwindjqgbbipfxehz] password: " -u root /bin/sh -c '”’”’“'”‘"’“'”‘“‘echo BECOME-SUCCESS-rczwjukcmjelutvbwindjqgbbipfxehz; /usr/bin/python’”’“'”‘"’“'”‘"’“’ && sleep 0’”‘"’’

`

you want:

ansible_ssh_common_args: -o ConnectTimeout=240s -o ControlMaster=auto
-o ControlPersist=60s -o ForwardAgent=yes

ansible_ssh_args does not exist, you DO have ssh_args in ansible.cfg
but that is 'global'.

OK, that certainly makes a difference. The output of -vvvv is now as expected and I’ll deploy that to may infrastructure and will watch the behavior the next couple of days, if that stabilizes the operations on that host.

Thanks Brian for your help.

It’s really strange. Still getting that timeout error although it is set differently:

`

TASK [Upgrade packages] ********************************************************
task path: /opt/ansible/playbooks/sanity.yml:36
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/packaging/os/apt.py
ESTABLISH SSH CONNECTION FOR USER: jurgenhaas
SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=jurgenhaas -o ConnectTimeout=10 -o ConnectTimeout=240s -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes -o ControlPath=/home/jurgenhaas/.ansible/cp/ansible-ssh-%h-%p-%r fimfcn1 ‘/bin/sh -c ‘"’“‘sudo -H -S -p “[sudo via ansible, key=ftwxuktzuptwgsqvjrvadpkstknljlfl] password: " -u root /bin/sh -c '”’”’“'”‘"’“'”‘“‘echo BECOME-SUCCESS-ftwxuktzuptwgsqvjrvadpkstknljlfl; /usr/bin/python’”’“'”‘"’“'”‘"’“’ && sleep 0’”‘"’’
fatal: [fimfcn1]: FAILED! => {
“failed”: true,
“msg”: "Timeout (12s) waiting for privilege escalation prompt: "
}

`

Any other idea I could go about? That error comes fairly early I have to say too, it isn’t waiting that long.

Also note that the 'displayed' timeout (12s) is the default value, not
inferred from ssh_args.