Remove provider (and transport, where applicable) from consideration when not using connection=local (#39555)
* Remove provider (and transport, where applicable) from consideration * Add tests that misplaced transport does not fail task
This commit is contained in:
parent
384a0d8b01
commit
c6270e15a6
14 changed files with 48 additions and 2 deletions
|
@ -49,6 +49,7 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['provider']
|
||||||
elif self._play_context.connection == 'local':
|
elif self._play_context.connection == 'local':
|
||||||
provider = load_provider(f5_provider_spec, self._task.args)
|
provider = load_provider(f5_provider_spec, self._task.args)
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['provider']
|
||||||
elif self._play_context.connection == 'local':
|
elif self._play_context.connection == 'local':
|
||||||
provider = load_provider(dellos10_provider_spec, self._task.args)
|
provider = load_provider(dellos10_provider_spec, self._task.args)
|
||||||
pc = copy.deepcopy(self._play_context)
|
pc = copy.deepcopy(self._play_context)
|
||||||
|
|
|
@ -49,6 +49,7 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['provider']
|
||||||
elif self._play_context.connection == 'local':
|
elif self._play_context.connection == 'local':
|
||||||
provider = load_provider(dellos6_provider_spec, self._task.args)
|
provider = load_provider(dellos6_provider_spec, self._task.args)
|
||||||
pc = copy.deepcopy(self._play_context)
|
pc = copy.deepcopy(self._play_context)
|
||||||
|
|
|
@ -49,6 +49,7 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['provider']
|
||||||
elif self._play_context.connection == 'local':
|
elif self._play_context.connection == 'local':
|
||||||
provider = load_provider(dellos9_provider_spec, self._task.args)
|
provider = load_provider(dellos9_provider_spec, self._task.args)
|
||||||
pc = copy.deepcopy(self._play_context)
|
pc = copy.deepcopy(self._play_context)
|
||||||
|
|
|
@ -47,6 +47,10 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['provider']
|
||||||
|
if self._task.args.get('transport'):
|
||||||
|
display.warning('transport is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['transport']
|
||||||
elif self._play_context.connection == 'local':
|
elif self._play_context.connection == 'local':
|
||||||
provider = load_provider(eos_provider_spec, self._task.args)
|
provider = load_provider(eos_provider_spec, self._task.args)
|
||||||
transport = provider['transport'] or 'cli'
|
transport = provider['transport'] or 'cli'
|
||||||
|
|
|
@ -47,6 +47,7 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['provider']
|
||||||
elif self._play_context.connection == 'local':
|
elif self._play_context.connection == 'local':
|
||||||
provider = load_provider(ios_provider_spec, self._task.args)
|
provider = load_provider(ios_provider_spec, self._task.args)
|
||||||
pc = copy.deepcopy(self._play_context)
|
pc = copy.deepcopy(self._play_context)
|
||||||
|
|
|
@ -81,6 +81,7 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using {0} and will be ignored'.format(self._play_context.connection))
|
display.warning('provider is unnecessary when using {0} and will be ignored'.format(self._play_context.connection))
|
||||||
|
del self._task.args['provider']
|
||||||
else:
|
else:
|
||||||
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}
|
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,8 @@ class ActionModule(_ActionModule):
|
||||||
elif self._play_context.connection in ('netconf', 'network_cli'):
|
elif self._play_context.connection in ('netconf', 'network_cli'):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using connection=%s and will be ignored' % self._play_context.connection)
|
display.warning('provider is unnecessary when using %s and will be ignored' % self._play_context.connection)
|
||||||
|
del self._task.args['provider']
|
||||||
|
|
||||||
if (self._play_context.connection == 'network_cli' and self._task.action not in CLI_SUPPORTED_MODULES) or \
|
if (self._play_context.connection == 'network_cli' and self._task.action not in CLI_SUPPORTED_MODULES) or \
|
||||||
(self._play_context.connection == 'netconf' and self._task.action == 'junos_netconf'):
|
(self._play_context.connection == 'netconf' and self._task.action == 'junos_netconf'):
|
||||||
|
|
|
@ -95,7 +95,8 @@ class ActionModule(ActionBase):
|
||||||
else:
|
else:
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using connection=%s and will be ignored' % play_context.connection)
|
display.warning('provider is unnecessary when using %s and will be ignored' % play_context.connection)
|
||||||
|
del self._task.args['provider']
|
||||||
|
|
||||||
if play_context.connection == 'network_cli':
|
if play_context.connection == 'network_cli':
|
||||||
# make sure we are in the right cli context which should be
|
# make sure we are in the right cli context which should be
|
||||||
|
|
|
@ -47,6 +47,10 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['provider']
|
||||||
|
if self._task.args.get('transport'):
|
||||||
|
display.warning('transport is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['transport']
|
||||||
elif self._play_context.connection == 'local':
|
elif self._play_context.connection == 'local':
|
||||||
provider = load_provider(nxos_provider_spec, self._task.args)
|
provider = load_provider(nxos_provider_spec, self._task.args)
|
||||||
transport = provider['transport'] or 'cli'
|
transport = provider['transport'] or 'cli'
|
||||||
|
|
|
@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['provider']
|
||||||
elif self._play_context.connection == 'local':
|
elif self._play_context.connection == 'local':
|
||||||
provider = load_provider(sros_provider_spec, self._task.args)
|
provider = load_provider(sros_provider_spec, self._task.args)
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ class ActionModule(_ActionModule):
|
||||||
provider = self._task.args.get('provider', {})
|
provider = self._task.args.get('provider', {})
|
||||||
if any(provider.values()):
|
if any(provider.values()):
|
||||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||||
|
del self._task.args['provider']
|
||||||
elif self._play_context.connection == 'local':
|
elif self._play_context.connection == 'local':
|
||||||
provider = load_provider(vyos_provider_spec, self._task.args)
|
provider = load_provider(vyos_provider_spec, self._task.args)
|
||||||
pc = copy.deepcopy(self._play_context)
|
pc = copy.deepcopy(self._play_context)
|
||||||
|
|
|
@ -23,4 +23,15 @@
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
become: no
|
become: no
|
||||||
|
|
||||||
|
# Test that transport values are properly ignored
|
||||||
|
- name: wrong transport specified
|
||||||
|
eos_command:
|
||||||
|
commands: show version
|
||||||
|
transport: eapi
|
||||||
|
|
||||||
|
- name: wrong transport specified in provider
|
||||||
|
eos_command:
|
||||||
|
commands: show version
|
||||||
|
provider: "{{ eapi }}"
|
||||||
|
|
||||||
when: "ansible_connection != 'local'"
|
when: "ansible_connection != 'local'"
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START cli/misc_tests.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
|
||||||
|
- block:
|
||||||
|
# Test that transport values are properly ignored
|
||||||
|
- name: wrong transport specified
|
||||||
|
eos_command:
|
||||||
|
commands: show version
|
||||||
|
transport: nxapi
|
||||||
|
|
||||||
|
- name: wrong transport specified in provider
|
||||||
|
eos_command:
|
||||||
|
commands: show version
|
||||||
|
provider: "{{ nxapi }}"
|
||||||
|
|
||||||
|
when: "ansible_connection != 'local'"
|
Loading…
Reference in a new issue