diff --git a/lib/ansible/modules/network/nxos/nxos_file_copy.py b/lib/ansible/modules/network/nxos/nxos_file_copy.py index 2044045c67..533dbec73a 100644 --- a/lib/ansible/modules/network/nxos/nxos_file_copy.py +++ b/lib/ansible/modules/network/nxos/nxos_file_copy.py @@ -56,6 +56,12 @@ options: their default values. required: false default: null + connect_ssh_port: + description: + - SSH port to connect to server during transfer of file + required: false + default: 22 + version_added: "2.5" ''' EXAMPLES = ''' @@ -63,6 +69,7 @@ EXAMPLES = ''' local_file: "./test_file.txt" remote_file: "test_file.txt" provider: "{{ cli }}" + connect_ssh_port: "{{ ansible_ssh_port }}" ''' RETURN = ''' @@ -148,13 +155,15 @@ def transfer_file(module, dest): hostname = module.params.get('host') or provider.get('host') username = module.params.get('username') or provider.get('username') password = module.params.get('password') or provider.get('password') + port = module.params.get('connect_ssh_port') ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect( hostname=hostname, username=username, - password=password) + password=password, + port=port) full_remote_path = '{}{}'.format(module.params['file_system'], dest) scp = SCPClient(ssh.get_transport()) @@ -181,6 +190,7 @@ def main(): local_file=dict(required=True), remote_file=dict(required=False), file_system=dict(required=False, default='bootflash:'), + connect_ssh_port=dict(required=False, type='int', default=22), ) argument_spec.update(nxos_argument_spec) diff --git a/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml b/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml index a3a2c29b8b..e3fbb91218 100644 --- a/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml +++ b/test/integration/targets/nxos_file_copy/tests/cli/sanity.yaml @@ -24,6 +24,7 @@ username: "{{ ansible_ssh_user }}" password: "{{ ansible_ssh_pass }}" host: "{{ ansible_host }}" + connect_ssh_port: "{{ ansible_ssh_port }}" register: result - assert: &true @@ -51,6 +52,7 @@ username: "{{ ansible_ssh_user }}" password: "{{ ansible_ssh_pass }}" host: "{{ ansible_host }}" + connect_ssh_port: "{{ ansible_ssh_port }}" register: result - assert: *true diff --git a/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml index b73c3e2c22..fc5db2e62b 100644 --- a/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml +++ b/test/integration/targets/nxos_file_copy/tests/nxapi/sanity.yaml @@ -26,6 +26,7 @@ username: "{{ ansible_ssh_user }}" password: "{{ ansible_ssh_pass }}" host: "{{ ansible_host }}" + connect_ssh_port: "{{ ansible_ssh_port }}" register: result - assert: &true @@ -54,6 +55,7 @@ username: "{{ ansible_ssh_user }}" password: "{{ ansible_ssh_pass }}" host: "{{ ansible_host }}" + connect_ssh_port: "{{ ansible_ssh_port }}" register: result - assert: *true