From d42151e6769fae0be9ae6a53e2f6709d3bed20be Mon Sep 17 00:00:00 2001 From: Chris Holland <41524756+ChrisAHolland@users.noreply.github.com> Date: Tue, 28 Apr 2020 07:36:22 -0700 Subject: [PATCH] Removed redundant conditional in paramiko_ssh.py (#69164) * Removed redundant conditional * Added changelog fragment * Removed trailing whitespace --- .../69164-remove-redundant-conditional.yaml | 2 ++ .../plugins/connection/paramiko_ssh.py | 28 +++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/69164-remove-redundant-conditional.yaml diff --git a/changelogs/fragments/69164-remove-redundant-conditional.yaml b/changelogs/fragments/69164-remove-redundant-conditional.yaml new file mode 100644 index 00000000000..97daa520c13 --- /dev/null +++ b/changelogs/fragments/69164-remove-redundant-conditional.yaml @@ -0,0 +1,2 @@ +bugfixes: +- paramiko_ssh - Removed redundant conditional statement in ``_parse_proxy_command`` that always evaluated to True. diff --git a/lib/ansible/plugins/connection/paramiko_ssh.py b/lib/ansible/plugins/connection/paramiko_ssh.py index 1ae971bfd61..9fd553f0bd0 100644 --- a/lib/ansible/plugins/connection/paramiko_ssh.py +++ b/lib/ansible/plugins/connection/paramiko_ssh.py @@ -255,21 +255,21 @@ class Connection(ConnectionBase): getattr(self._play_context, 'ssh_common_args', '') or '', getattr(self._play_context, 'ssh_args', '') or '', ] - if ssh_args is not None: - args = self._split_ssh_args(' '.join(ssh_args)) - for i, arg in enumerate(args): - if arg.lower() == 'proxycommand': - # _split_ssh_args split ProxyCommand from the command itself - proxy_command = args[i + 1] - else: - # ProxyCommand and the command itself are a single string - match = SETTINGS_REGEX.match(arg) - if match: - if match.group(1).lower() == 'proxycommand': - proxy_command = match.group(2) - if proxy_command: - break + args = self._split_ssh_args(' '.join(ssh_args)) + for i, arg in enumerate(args): + if arg.lower() == 'proxycommand': + # _split_ssh_args split ProxyCommand from the command itself + proxy_command = args[i + 1] + else: + # ProxyCommand and the command itself are a single string + match = SETTINGS_REGEX.match(arg) + if match: + if match.group(1).lower() == 'proxycommand': + proxy_command = match.group(2) + + if proxy_command: + break proxy_command = proxy_command or self.get_option('proxy_command')