From b4184aa50e902131e1d970ffcd2588fb199d11d2 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Thu, 2 Jul 2020 15:04:58 -0400 Subject: [PATCH] ssh connection - use get_option() rather than _play_context (#70438) The ssh_args were sometimes not correctly applied to the connection when using _play_context. Use get_option() instead to ensure the correct ssh_args are always applied. --- changelogs/fragments/70437-ssh-args.yml | 4 ++++ lib/ansible/plugins/connection/ssh.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/70437-ssh-args.yml diff --git a/changelogs/fragments/70437-ssh-args.yml b/changelogs/fragments/70437-ssh-args.yml new file mode 100644 index 00000000000..3a1af9d5612 --- /dev/null +++ b/changelogs/fragments/70437-ssh-args.yml @@ -0,0 +1,4 @@ +bugfixes: + - > + ssh connection plugin - use ``get_option()`` rather than ``_play_context`` to + ensure ``ANSBILE_SSH_ARGS`` are applied properly (https://github.com/ansible/ansible/issues/70437) diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 924604421b1..ed44a035fe0 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -611,9 +611,10 @@ class Connection(ConnectionBase): # Next, we add [ssh_connection]ssh_args from ansible.cfg. # - if self._play_context.ssh_args: + ssh_args = self.get_option('ssh_args') + if ssh_args: b_args = [to_bytes(a, errors='surrogate_or_strict') for a in - self._split_ssh_args(self._play_context.ssh_args)] + self._split_ssh_args(ssh_args)] self._add_args(b_command, b_args, u"ansible.cfg set ssh_args") # Now we add various arguments controlled by configuration file settings