Fix ansible-connection persist after playbook run complete issue (#61591)

* Fix ansible-connection persist after playbook run issue

*  PR https://github.com/ansible/ansible/pull/59153 to add support
   for delaying the ansible-connection added an old issue of
   ansible-connection persisting even after playbook run is finished
   till either command timeout or connect timeout is triggered.
   ansible-connection persist after playbook execution is done
   and also delays the connection initilization untill a method
   in invoked from module side on the connection object.

* Add chanegelog
pull/61925/head
Ganesh Nalawade 5 years ago committed by GitHub
parent e6fe52bc56
commit 4f29b5a76b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- ansible-connection persists even after playbook run is completed (https://github.com/ansible/ansible/pull/61591)

@ -120,7 +120,7 @@ class ConnectionProcess(object):
def run(self): def run(self):
try: try:
while True: while not self.connection._conn_closed:
signal.signal(signal.SIGALRM, self.connect_timeout) signal.signal(signal.SIGALRM, self.connect_timeout)
signal.signal(signal.SIGTERM, self.handler) signal.signal(signal.SIGTERM, self.handler)
signal.alarm(self.connection.get_option('persistent_connect_timeout')) signal.alarm(self.connection.get_option('persistent_connect_timeout'))

@ -275,6 +275,7 @@ class NetworkConnectionBase(ConnectionBase):
def __init__(self, play_context, new_stdin, *args, **kwargs): def __init__(self, play_context, new_stdin, *args, **kwargs):
super(NetworkConnectionBase, self).__init__(play_context, new_stdin, *args, **kwargs) super(NetworkConnectionBase, self).__init__(play_context, new_stdin, *args, **kwargs)
self._messages = [] self._messages = []
self._conn_closed = False
self._network_os = self._play_context.network_os self._network_os = self._play_context.network_os
@ -335,6 +336,7 @@ class NetworkConnectionBase(ConnectionBase):
self.queue_message('vvvv', 'reset call on connection instance') self.queue_message('vvvv', 'reset call on connection instance')
def close(self): def close(self):
self._conn_closed = True
if self._connected: if self._connected:
self._connected = False self._connected = False

Loading…
Cancel
Save