[stable-2.10] Fix reset_connection paramiko, winrm, psrp (#72688) (#72925)

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

* Ensure psrp doesn't trace

* winrm too

* Indentation fix
(cherry picked from commit a3b6485)

Co-authored-by: Matt Martz <matt@sivel.net>
This commit is contained in:
Matt Martz 2021-01-11 00:36:05 -06:00 committed by GitHub
parent 82b75282fc
commit 511ffdeff7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 0 deletions

View file

@ -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)

View file

@ -536,6 +536,8 @@ class Connection(ConnectionBase):
f.write("%s %s %s\n" % (hostname, keytype, key.get_base64())) f.write("%s %s %s\n" % (hostname, keytype, key.get_base64()))
def reset(self): def reset(self):
if not self._connected:
return
self.close() self.close()
self._connect() self._connect()

View file

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

View file

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

View file

@ -21,3 +21,5 @@ then
else else
echo "SUCCESS: Connection vars not found" echo "SUCCESS: Connection vars not found"
fi fi
ansible-playbook test_reset_connection.yml -i "${INVENTORY}" "$@"

View file

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