diff --git a/lib/ansible/plugins/action/bigip.py b/lib/ansible/plugins/action/bigip.py index f4e399982f3..8f904c3572d 100644 --- a/lib/ansible/plugins/action/bigip.py +++ b/lib/ansible/plugins/action/bigip.py @@ -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) diff --git a/lib/ansible/plugins/action/dellos10.py b/lib/ansible/plugins/action/dellos10.py index 4bc461f8dff..7a45cf84bd1 100644 --- a/lib/ansible/plugins/action/dellos10.py +++ b/lib/ansible/plugins/action/dellos10.py @@ -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) diff --git a/lib/ansible/plugins/action/dellos6.py b/lib/ansible/plugins/action/dellos6.py index b469cefab4f..2a25494aa29 100644 --- a/lib/ansible/plugins/action/dellos6.py +++ b/lib/ansible/plugins/action/dellos6.py @@ -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) diff --git a/lib/ansible/plugins/action/dellos9.py b/lib/ansible/plugins/action/dellos9.py index 85b518f8f02..d7c8156d8c0 100644 --- a/lib/ansible/plugins/action/dellos9.py +++ b/lib/ansible/plugins/action/dellos9.py @@ -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) diff --git a/lib/ansible/plugins/action/eos.py b/lib/ansible/plugins/action/eos.py index 3cb17667154..c7a25cd3d29 100644 --- a/lib/ansible/plugins/action/eos.py +++ b/lib/ansible/plugins/action/eos.py @@ -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' diff --git a/lib/ansible/plugins/action/ios.py b/lib/ansible/plugins/action/ios.py index 2cfca1a374b..1a501660867 100644 --- a/lib/ansible/plugins/action/ios.py +++ b/lib/ansible/plugins/action/ios.py @@ -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) diff --git a/lib/ansible/plugins/action/iosxr.py b/lib/ansible/plugins/action/iosxr.py index 9c978a21f0e..6c16a110c5f 100644 --- a/lib/ansible/plugins/action/iosxr.py +++ b/lib/ansible/plugins/action/iosxr.py @@ -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} diff --git a/lib/ansible/plugins/action/junos.py b/lib/ansible/plugins/action/junos.py index 64913c14be9..8a436d22fd5 100644 --- a/lib/ansible/plugins/action/junos.py +++ b/lib/ansible/plugins/action/junos.py @@ -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'): diff --git a/lib/ansible/plugins/action/net_base.py b/lib/ansible/plugins/action/net_base.py index dd0fcf6d3e1..cd1c2121af8 100644 --- a/lib/ansible/plugins/action/net_base.py +++ b/lib/ansible/plugins/action/net_base.py @@ -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 diff --git a/lib/ansible/plugins/action/nxos.py b/lib/ansible/plugins/action/nxos.py index 44baa65aa19..bf97fe14380 100644 --- a/lib/ansible/plugins/action/nxos.py +++ b/lib/ansible/plugins/action/nxos.py @@ -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' diff --git a/lib/ansible/plugins/action/sros.py b/lib/ansible/plugins/action/sros.py index 3bff1b7a30d..e4c346329c7 100644 --- a/lib/ansible/plugins/action/sros.py +++ b/lib/ansible/plugins/action/sros.py @@ -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) diff --git a/lib/ansible/plugins/action/vyos.py b/lib/ansible/plugins/action/vyos.py index 5e12dffc06b..102c6ecb117 100644 --- a/lib/ansible/plugins/action/vyos.py +++ b/lib/ansible/plugins/action/vyos.py @@ -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) diff --git a/test/integration/targets/eos_smoke/tests/cli/misc_tests.yaml b/test/integration/targets/eos_smoke/tests/cli/misc_tests.yaml index 3d8297e3b91..c38e194df6f 100644 --- a/test/integration/targets/eos_smoke/tests/cli/misc_tests.yaml +++ b/test/integration/targets/eos_smoke/tests/cli/misc_tests.yaml @@ -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'" diff --git a/test/integration/targets/nxos_smoke/tests/cli/misc_tests.yaml b/test/integration/targets/nxos_smoke/tests/cli/misc_tests.yaml new file mode 100644 index 00000000000..9bb1435e61f --- /dev/null +++ b/test/integration/targets/nxos_smoke/tests/cli/misc_tests.yaml @@ -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'"