mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
nxos_file_copy network_cli and httpapi fix (#40592)
* Leverage action plugin to pass credentials to nxos_file_copy for network_cli, httpapi Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update integration test Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * make sure local test uses provider Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update tests Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update doc Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * clarify action plugin comment Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add connection=local back to nxos_file_copy because that module is weird Also blacklist it running on nxapi, because that is meaningless * remove provider Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * blacklist nxapi Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Address review comment Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
parent
94049680c3
commit
c2f7f36fc5
7 changed files with 46 additions and 112 deletions
|
@ -44,9 +44,17 @@ class ActionModule(_ActionModule):
|
|||
socket_path = None
|
||||
|
||||
if (self._play_context.connection == 'httpapi' or self._task.args.get('provider', {}).get('transport') == 'nxapi') \
|
||||
and self._task.action == 'nxos_nxapi':
|
||||
and self._task.action in ('nxos_file_copy', 'nxos_nxapi'):
|
||||
return {'failed': True, 'msg': "Transport type 'nxapi' is not valid for '%s' module." % (self._task.action)}
|
||||
|
||||
if self._task.action == 'nxos_file_copy':
|
||||
self._task.args['host'] = self._play_context.remote_addr
|
||||
self._task.args['password'] = self._play_context.password
|
||||
if self._play_context.connection == 'network_cli':
|
||||
self._task.args['username'] = self._play_context.remote_user
|
||||
elif self._play_context.connection == 'local':
|
||||
self._task.args['username'] = self._play_context.connection_user
|
||||
|
||||
if self._play_context.connection in ('network_cli', 'httpapi'):
|
||||
provider = self._task.args.get('provider', {})
|
||||
if any(provider.values()):
|
||||
|
@ -55,6 +63,7 @@ class ActionModule(_ActionModule):
|
|||
if self._task.args.get('transport'):
|
||||
display.warning('transport is unnecessary when using %s and will be ignored' % self._play_context.connection)
|
||||
del self._task.args['transport']
|
||||
|
||||
elif self._play_context.connection == 'local':
|
||||
provider = load_provider(nxos_provider_spec, self._task.args)
|
||||
transport = provider['transport'] or 'cli'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue