From 2ce007fb9a4a8d70e634122a29e8754e7e9516ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Wed, 24 Nov 2021 19:26:10 +0100 Subject: [PATCH] fix ssh cli defaults (#75245) (#76347) * fix ssh cli defaults fixes #75221 (cherry picked from commit e5a2fe4c419740e9a709b07b064063f54277b983) Co-authored-by: Brian Coca --- changelogs/fragments/fix_cli_ssh_defaults.yml | 2 ++ lib/ansible/cli/arguments/option_helpers.py | 8 ++++---- lib/ansible/plugins/connection/ssh.py | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/fix_cli_ssh_defaults.yml diff --git a/changelogs/fragments/fix_cli_ssh_defaults.yml b/changelogs/fragments/fix_cli_ssh_defaults.yml new file mode 100644 index 00000000000..65d26768c9c --- /dev/null +++ b/changelogs/fragments/fix_cli_ssh_defaults.yml @@ -0,0 +1,2 @@ +bugfixes: + - cli defaults for ssh args set to None as '' was bypassing normal default. diff --git a/lib/ansible/cli/arguments/option_helpers.py b/lib/ansible/cli/arguments/option_helpers.py index e18cd6ce9ae..4f8c9f889dc 100644 --- a/lib/ansible/cli/arguments/option_helpers.py +++ b/lib/ansible/cli/arguments/option_helpers.py @@ -253,13 +253,13 @@ def add_connect_options(parser): help="connection type to use (default=%s)" % C.DEFAULT_TRANSPORT) connect_group.add_argument('-T', '--timeout', default=C.DEFAULT_TIMEOUT, type=int, dest='timeout', help="override the connection timeout in seconds (default=%s)" % C.DEFAULT_TIMEOUT) - connect_group.add_argument('--ssh-common-args', default='', dest='ssh_common_args', + connect_group.add_argument('--ssh-common-args', default=None, dest='ssh_common_args', help="specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand)") - connect_group.add_argument('--sftp-extra-args', default='', dest='sftp_extra_args', + connect_group.add_argument('--sftp-extra-args', default=None, dest='sftp_extra_args', help="specify extra arguments to pass to sftp only (e.g. -f, -l)") - connect_group.add_argument('--scp-extra-args', default='', dest='scp_extra_args', + connect_group.add_argument('--scp-extra-args', default=None, dest='scp_extra_args', help="specify extra arguments to pass to scp only (e.g. -l)") - connect_group.add_argument('--ssh-extra-args', default='', dest='ssh_extra_args', + connect_group.add_argument('--ssh-extra-args', default=None, dest='ssh_extra_args', help="specify extra arguments to pass to ssh only (e.g. -R)") parser.add_argument_group(connect_group) diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 4f0ffc8abe6..3c02b9fbdb9 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -83,6 +83,7 @@ DOCUMENTATION = ''' version_added: '2.7' vars: - name: ansible_ssh_common_args + default: '' ssh_executable: default: ssh description: @@ -130,6 +131,7 @@ DOCUMENTATION = ''' - key: scp_extra_args section: ssh_connection version_added: '2.7' + default: '' sftp_extra_args: description: Extra exclusive to the ``sftp`` CLI vars: @@ -141,6 +143,7 @@ DOCUMENTATION = ''' - key: sftp_extra_args section: ssh_connection version_added: '2.7' + default: '' ssh_extra_args: description: Extra exclusive to the 'ssh' CLI vars: @@ -152,6 +155,7 @@ DOCUMENTATION = ''' - key: ssh_extra_args section: ssh_connection version_added: '2.7' + default: '' retries: # constant: ANSIBLE_SSH_RETRIES description: Number of attempts to connect.