Remove provider (and transport, where applicable) from consideration when not using connection=local (#39555) (#39861)

* Remove provider (and transport, where applicable) from consideration

* Add tests that misplaced transport does not fail task

(cherry picked from commit c6270e15a6)
pull/39871/head
Nathaniel Case 7 years ago committed by GitHub
parent fb5bc5d513
commit f654d47c01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -49,6 +49,7 @@ class ActionModule(_ActionModule):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(f5_provider_spec, self._task.args)

@ -49,6 +49,7 @@ class ActionModule(_ActionModule):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(dellos10_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)

@ -49,6 +49,7 @@ class ActionModule(_ActionModule):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(dellos6_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)

@ -49,6 +49,7 @@ class ActionModule(_ActionModule):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(dellos9_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)

@ -47,6 +47,10 @@ class ActionModule(_ActionModule):
provider = self._task.args.get('provider', {})
if any(provider.values()):
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':
provider = load_provider(eos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli'

@ -47,6 +47,7 @@ class ActionModule(_ActionModule):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(ios_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)

@ -81,6 +81,7 @@ class ActionModule(_ActionModule):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using {0} and will be ignored'.format(self._play_context.connection))
del self._task.args['provider']
else:
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'):
provider = self._task.args.get('provider', {})
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 \
(self._play_context.connection == 'netconf' and self._task.action == 'junos_netconf'):

@ -95,7 +95,8 @@ class ActionModule(ActionBase):
else:
provider = self._task.args.get('provider', {})
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':
# 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', {})
if any(provider.values()):
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':
provider = load_provider(nxos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli'

@ -43,6 +43,7 @@ class ActionModule(_ActionModule):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(sros_provider_spec, self._task.args)

@ -47,6 +47,7 @@ class ActionModule(_ActionModule):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(vyos_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)

@ -23,4 +23,15 @@
provider: "{{ cli }}"
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'"

@ -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…
Cancel
Save