From 578ae3b238d54da99122838df01b5d4aafceab34 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Wed, 13 Sep 2017 16:36:41 +0530 Subject: [PATCH] fix nxos_file_copy and provider getting set to None when transport is cli (#30262) * nxos_file_copy bug fix Signed-off-by: Trishna Guha * provider gets set to None in module level when transport is cli Signed-off-by: Trishna Guha --- lib/ansible/modules/network/nxos/nxos_file_copy.py | 13 +++++++------ lib/ansible/plugins/action/nxos.py | 7 ------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_file_copy.py b/lib/ansible/modules/network/nxos/nxos_file_copy.py index 33a34bd886..2044045c67 100644 --- a/lib/ansible/modules/network/nxos/nxos_file_copy.py +++ b/lib/ansible/modules/network/nxos/nxos_file_copy.py @@ -61,9 +61,8 @@ options: EXAMPLES = ''' - nxos_file_copy: local_file: "./test_file.txt" - username: "{{ un }}" - password: "{{ pwd }}" - host: "{{ inventory_hostname }}" + remote_file: "test_file.txt" + provider: "{{ cli }}" ''' RETURN = ''' @@ -144,9 +143,11 @@ def transfer_file(module, dest): if not enough_space(module): module.fail_json(msg='Could not transfer file. Not enough space on device.') - hostname = module.params['host'] - username = module.params['username'] - password = module.params['password'] + provider = module.params['provider'] + + 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') ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) diff --git a/lib/ansible/plugins/action/nxos.py b/lib/ansible/plugins/action/nxos.py index 0b3ea4d114..b1feccfd28 100644 --- a/lib/ansible/plugins/action/nxos.py +++ b/lib/ansible/plugins/action/nxos.py @@ -59,13 +59,6 @@ class ActionModule(_ActionModule): pc.password = provider['password'] or self._play_context.password pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file pc.timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT) - self._task.args['provider'] = provider.update( - host=pc.remote_addr, - port=pc.port, - username=pc.remote_user, - password=pc.password, - ssh_keyfile=pc.private_key_file - ) display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr) connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)