[stable-2.9] Fix reset_connection paramiko, winrm, psrp (#72688) (#72926)

* Ensure we only reset the connection when one has been previously established. Fixes #65812

* Ensure psrp doesn't trace

* winrm too

(cherry picked from commit a3b6485073)

Co-authored-by: Matt Martz <matt@sivel.net>
pull/73178/head
Matt Martz 5 years ago committed by GitHub
parent c32371db56
commit ead63f2021
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- paramiko connection plugin - Ensure we only reset the connection when one has been
previously established (https://github.com/ansible/ansible/issues/65812)

@ -538,6 +538,8 @@ class Connection(ConnectionBase):
f.close()
def reset(self):
if not self._connected:
return
self.close()
self._connect()

@ -407,6 +407,8 @@ class Connection(ConnectionBase):
return self
def reset(self):
if not self._connected:
return
display.vvvvv("PSRP: Reset Connection", host=self._psrp_host)
self.runspace = None
self._connect()

@ -525,6 +525,8 @@ class Connection(ConnectionBase):
return self
def reset(self):
if not self._connected:
return
self.protocol = None
self.shell_id = None
self._connect()

@ -8,3 +8,5 @@ set -eux
ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
LC_ALL=C LANG=C ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
ansible-playbook test_reset_connection.yml -i "${INVENTORY}" "$@"

@ -0,0 +1,5 @@
- hosts: "{{ target_hosts }}"
gather_facts: no
tasks:
# https://github.com/ansible/ansible/issues/65812
- meta: reset_connection
Loading…
Cancel
Save