summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Sprygada <privateip@users.noreply.github.com>2017-03-14 10:31:02 -0400
committerGitHub <noreply@github.com>2017-03-14 10:31:02 -0400
commiteed240797aed30a0e42a9d2cb6cdded16d75fb5c (patch)
tree2a98778a824acf0260eafae99583a9f0c814809f
parent771b14acb2270ed341fc41b3d77acaa1032f7072 (diff)
downloadansible-eed240797aed30a0e42a9d2cb6cdded16d75fb5c.tar.gz
adds connection established message to ansible-connection (#22492)
This will now print a log message that displays how long the ssh connection took to establish to the remote device. If the connection established time is exceed it will also print a message to the log file that the connection attempts have exceed. Updates default connection retries to 30 fixes #22319
-rwxr-xr-xbin/ansible-connection5
-rw-r--r--lib/ansible/constants.py2
2 files changed, 6 insertions, 1 deletions
diff --git a/bin/ansible-connection b/bin/ansible-connection
index cca24df7a2..9c053e0531 100755
--- a/bin/ansible-connection
+++ b/bin/ansible-connection
@@ -126,6 +126,9 @@ class Server():
if not self.conn.connected:
raise AnsibleConnectionFailure('unable to connect to remote host')
+ connection_time = datetime.datetime.now() - self._start_time
+ display.vvvv('connection established in %s' % connection_time, play_context.remote_addr)
+
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.socket.bind(path)
self.socket.listen(1)
@@ -321,6 +324,8 @@ def main():
time.sleep(C.PERSISTENT_CONNECT_INTERVAL)
attempts += 1
if attempts > C.PERSISTENT_CONNECT_RETRIES:
+ display.vvvv('number of connection attempts exceeded, unable to connect to control socket')
+ display.vvvv('persistent_connect_interval=%s, persistent_connect_retries=%s' % (C.PERSISTENT_CONNECT_INTERVAL, C.PERSISTENT_CONNECT_RETRIES))
sys.stderr.write('failed to connect to control socket')
sys.exit(255)
diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py
index 6116fae27c..1f00afcdcb 100644
--- a/lib/ansible/constants.py
+++ b/lib/ansible/constants.py
@@ -347,7 +347,7 @@ PARAMIKO_HOST_KEY_AUTO_ADD = get_config(p, 'paramiko_connection', 'host_key_
PARAMIKO_PROXY_COMMAND = get_config(p, 'paramiko_connection', 'proxy_command', 'ANSIBLE_PARAMIKO_PROXY_COMMAND', None)
PARAMIKO_LOOK_FOR_KEYS = get_config(p, 'paramiko_connection', 'look_for_keys', 'ANSIBLE_PARAMIKO_LOOK_FOR_KEYS', True, value_type='boolean')
PERSISTENT_CONNECT_TIMEOUT = get_config(p, 'persistent_connection', 'connect_timeout', 'ANSIBLE_PERSISTENT_CONNECT_TIMEOUT', 30, value_type='integer')
-PERSISTENT_CONNECT_RETRIES = get_config(p, 'persistent_connection', 'connect_retries', 'ANSIBLE_PERSISTENT_CONNECT_RETRIES', 10, value_type='integer')
+PERSISTENT_CONNECT_RETRIES = get_config(p, 'persistent_connection', 'connect_retries', 'ANSIBLE_PERSISTENT_CONNECT_RETRIES', 30, value_type='integer')
PERSISTENT_CONNECT_INTERVAL = get_config(p, 'persistent_connection', 'connect_interval', 'ANSIBLE_PERSISTENT_CONNECT_INTERVAL', 1, value_type='integer')
# obsolete -- will be formally removed