mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add port arg to establish ssh connection in nxos_file_copy (#33304)
* Add port arg to establish ssh connection in nxos_file_copy Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * resolve kedar's comment
This commit is contained in:
parent
a18b7d9b01
commit
819f9ee8fa
3 changed files with 15 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue