Skip to content
Browse files

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
  • Loading branch information...
privateip committed Mar 14, 2017
1 parent 771b14a commit eed240797aed30a0e42a9d2cb6cdded16d75fb5c
Showing with 6 additions and 1 deletion.
  1. +5 −0 bin/ansible-connection
  2. +1 −1 lib/ansible/
@@ -126,6 +126,9 @@ class Server():
if not self.conn.connected:
raise AnsibleConnectionFailure('unable to connect to remote host')

connection_time = - 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)
@@ -321,6 +324,8 @@ def main():
attempts += 1
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')

@@ -347,7 +347,7 @@ def load_config_file():
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

0 comments on commit eed2407

Please sign in to comment.
You can’t perform that action at this time.