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 dc3a88b53cb..7492e781c55 100644 --- a/lib/ansible/cli/arguments/option_helpers.py +++ b/lib/ansible/cli/arguments/option_helpers.py @@ -261,13 +261,13 @@ def add_connect_options(parser): help="override the connection timeout in seconds (default=%s)" % C.DEFAULT_TIMEOUT) # ssh only - 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 be371900522..3f812c1cb18 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -92,6 +92,7 @@ DOCUMENTATION = ''' - name: ansible_ssh_common_args cli: - name: ssh_common_args + default: '' ssh_executable: default: ssh description: @@ -141,6 +142,7 @@ DOCUMENTATION = ''' version_added: '2.7' cli: - name: scp_extra_args + default: '' sftp_extra_args: description: Extra exclusive to the ``sftp`` CLI vars: @@ -154,8 +156,10 @@ DOCUMENTATION = ''' version_added: '2.7' cli: - name: sftp_extra_args + default: '' ssh_extra_args: description: Extra exclusive to the 'ssh' CLI + default: '' vars: - name: ansible_ssh_extra_args env: