From 2c93b220438797581dc34232f67ce08a2f8ad33b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 11 May 2021 14:49:56 -0400 Subject: [PATCH] use self.host which will always be updated (#74574) * use self.host which will always be updated pc remote_addr is not correctly updated in all cases --- changelogs/fragments/ssh_cleanup.yml | 2 ++ lib/ansible/plugins/connection/ssh.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/ssh_cleanup.yml diff --git a/changelogs/fragments/ssh_cleanup.yml b/changelogs/fragments/ssh_cleanup.yml new file mode 100644 index 00000000000..79a4569c8f6 --- /dev/null +++ b/changelogs/fragments/ssh_cleanup.yml @@ -0,0 +1,2 @@ +bugfixes: + - ssh connection, use self.host which has the most up2date info instead of pc.remote_addr diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 02d776e14b7..e4cb6c4f48e 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -601,7 +601,7 @@ class Connection(ConnectionBase): were added. It will be displayed with a high enough verbosity. .. note:: This function does its work via side-effect. The b_command list has the new arguments appended. """ - display.vvvvv(u'SSH: %s: (%s)' % (explanation, ')('.join(to_text(a) for a in b_args)), host=self._play_context.remote_addr) + display.vvvvv(u'SSH: %s: (%s)' % (explanation, ')('.join(to_text(a) for a in b_args)), host=self.host) b_command += b_args def _build_command(self, binary, subsystem, *other_args): @@ -1232,7 +1232,7 @@ class Connection(ConnectionBase): super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable) - display.vvv(u"ESTABLISH SSH CONNECTION FOR USER: {0}".format(self.user), host=self._play_context.remote_addr) + display.vvv(u"ESTABLISH SSH CONNECTION FOR USER: {0}".format(self.user), host=self.host) if getattr(self._shell, "_IS_WINDOWS", False): # Become method 'runas' is done in the wrapper that is executed,