diff --git a/changelogs/fragments/network_action_plugin_fixes.yml b/changelogs/fragments/network_action_plugin_fixes.yml new file mode 100644 index 00000000000..5f58ed7e556 --- /dev/null +++ b/changelogs/fragments/network_action_plugin_fixes.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fixes in network action plugins to work in network connection plugin and modules in collection diff --git a/lib/ansible/plugins/action/aireos.py b/lib/ansible/plugins/action/aireos.py index d10d6353f2a..8ca0f8d62a6 100644 --- a/lib/ansible/plugins/action/aireos.py +++ b/lib/ansible/plugins/action/aireos.py @@ -36,7 +36,8 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'aireos_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'aireos_config' else False if self._play_context.connection != 'local': return dict( diff --git a/lib/ansible/plugins/action/aruba.py b/lib/ansible/plugins/action/aruba.py index 4763a5d257d..f7e3c748d45 100644 --- a/lib/ansible/plugins/action/aruba.py +++ b/lib/ansible/plugins/action/aruba.py @@ -36,7 +36,8 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'aruba_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'aruba_config' else False if self._play_context.connection != 'local': return dict( diff --git a/lib/ansible/plugins/action/asa.py b/lib/ansible/plugins/action/asa.py index b58d18e71f1..c12216976c2 100644 --- a/lib/ansible/plugins/action/asa.py +++ b/lib/ansible/plugins/action/asa.py @@ -37,7 +37,8 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'asa_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'asa_config' else False if self._play_context.connection == 'local': provider = load_provider(asa_provider_spec, self._task.args) diff --git a/lib/ansible/plugins/action/bigip.py b/lib/ansible/plugins/action/bigip.py index 0103d757f2e..e400a2f9173 100644 --- a/lib/ansible/plugins/action/bigip.py +++ b/lib/ansible/plugins/action/bigip.py @@ -43,11 +43,13 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'bigip_imish_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'bigip_imish_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] socket_path = None transport = 'rest' - if self._play_context.connection == 'network_cli': + if persistent_connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning("'provider' is unnecessary when using 'network_cli' and will be ignored") @@ -83,7 +85,7 @@ class ActionModule(ActionNetworkModule): task_vars['ansible_socket'] = socket_path - if (self._play_context.connection == 'local' and transport == 'cli') or self._play_context.connection == 'network_cli': + if (self._play_context.connection == 'local' and transport == 'cli') or persistent_connection == 'network_cli': # make sure we are in the right cli context which should be # enable mode and not config module if socket_path is None: diff --git a/lib/ansible/plugins/action/bigiq.py b/lib/ansible/plugins/action/bigiq.py index 8b4bd15fc51..f4bf8d09e9a 100644 --- a/lib/ansible/plugins/action/bigiq.py +++ b/lib/ansible/plugins/action/bigiq.py @@ -43,8 +43,9 @@ class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): socket_path = None transport = 'rest' + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection == 'network_cli': + if persistent_connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning("'provider' is unnecessary when using 'network_cli' and will be ignored") @@ -78,7 +79,7 @@ class ActionModule(_ActionModule): task_vars['ansible_socket'] = socket_path - if (self._play_context.connection == 'local' and transport == 'cli') or self._play_context.connection == 'network_cli': + if (self._play_context.connection == 'local' and transport == 'cli') or persistent_connection == 'network_cli': # make sure we are in the right cli context which should be # enable mode and not config module if socket_path is None: diff --git a/lib/ansible/plugins/action/ce.py b/lib/ansible/plugins/action/ce.py index 54093ac39c6..2db9da1e3ff 100644 --- a/lib/ansible/plugins/action/ce.py +++ b/lib/ansible/plugins/action/ce.py @@ -31,8 +31,10 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'ce_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'ce_config' else False socket_path = None + persistent_connection = self._play_context.connection.split('.')[-1] if self._play_context.connection == 'local': provider = load_provider(ce_provider_spec, self._task.args) @@ -55,7 +57,7 @@ class ActionModule(ActionNetworkModule): username=pc.remote_user, password=pc.password ) - if self._task.action in ['ce_netconf'] or self._task.action not in CLI_SUPPORTED_MODULES: + if module_name in ['ce_netconf'] or module_name not in CLI_SUPPORTED_MODULES: pc.connection = 'netconf' display.vvv('using connection plugin %s (was local)' % pc.connection, pc.remote_addr) connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin, task_uuid=self._task._uuid) @@ -72,14 +74,14 @@ class ActionModule(ActionNetworkModule): # make sure a transport value is set in args self._task.args['transport'] = transport self._task.args['provider'] = provider - elif self._play_context.connection in ('netconf', 'network_cli'): + elif persistent_connection in ('netconf', 'network_cli'): provider = self._task.args.get('provider', {}) if any(provider.values()): 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 in CLI_SUPPORTED_MODULES): + if (persistent_connection == 'network_cli' and module_name not in CLI_SUPPORTED_MODULES) or \ + (persistent_connection == 'netconf' and module_name in CLI_SUPPORTED_MODULES): return {'failed': True, 'msg': "Connection type '%s' is not valid for '%s' module." % (self._play_context.connection, self._task.action)} diff --git a/lib/ansible/plugins/action/cli_command.py b/lib/ansible/plugins/action/cli_command.py index ff191f56212..15052e1b584 100644 --- a/lib/ansible/plugins/action/cli_command.py +++ b/lib/ansible/plugins/action/cli_command.py @@ -25,7 +25,7 @@ from ansible.plugins.action.normal import ActionModule as _ActionModule class ActionModule(_ActionModule): def run(self, tmp=None, task_vars=None): - if self._play_context.connection != 'network_cli': + if self._play_context.connection.split('.')[-1] != 'network_cli': return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection} return super(ActionModule, self).run(task_vars=task_vars) diff --git a/lib/ansible/plugins/action/cli_config.py b/lib/ansible/plugins/action/cli_config.py index 1bf30c584be..0f2753625ec 100644 --- a/lib/ansible/plugins/action/cli_config.py +++ b/lib/ansible/plugins/action/cli_config.py @@ -28,7 +28,7 @@ class ActionModule(ActionNetworkModule): del tmp # tmp no longer has any effect self._config_module = True - if self._play_context.connection != 'network_cli': + if self._play_context.connection.split('.')[-1] != 'network_cli': return {'failed': True, 'msg': 'Connection type %s is not valid for cli_config module' % self._play_context.connection} return super(ActionModule, self).run(task_vars=task_vars) diff --git a/lib/ansible/plugins/action/cnos.py b/lib/ansible/plugins/action/cnos.py index 5120b4ae91d..4914d12141f 100644 --- a/lib/ansible/plugins/action/cnos.py +++ b/lib/ansible/plugins/action/cnos.py @@ -34,7 +34,8 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'cnos_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'cnos_config' else False if self._play_context.connection == 'local': provider = load_provider(cnos_provider_spec, self._task.args) diff --git a/lib/ansible/plugins/action/dellos10.py b/lib/ansible/plugins/action/dellos10.py index ec8423626ea..9f2fe6c3605 100644 --- a/lib/ansible/plugins/action/dellos10.py +++ b/lib/ansible/plugins/action/dellos10.py @@ -38,9 +38,11 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'dellos10_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'dellos10_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection == 'network_cli': + if persistent_connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning('provider is unnecessary when using network_cli and will be ignored') diff --git a/lib/ansible/plugins/action/dellos6.py b/lib/ansible/plugins/action/dellos6.py index 98b4596dbd0..cb5e0eaecf5 100644 --- a/lib/ansible/plugins/action/dellos6.py +++ b/lib/ansible/plugins/action/dellos6.py @@ -38,10 +38,12 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'dellos6_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'dellos6_config' else False socket_path = None + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection == 'network_cli': + if persistent_connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning('provider is unnecessary when using network_cli and will be ignored') diff --git a/lib/ansible/plugins/action/dellos9.py b/lib/ansible/plugins/action/dellos9.py index 7e79b3219e1..6500e165c6f 100644 --- a/lib/ansible/plugins/action/dellos9.py +++ b/lib/ansible/plugins/action/dellos9.py @@ -38,10 +38,12 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'dellos9_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'dellos9_config' else False socket_path = None + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection == 'network_cli': + if persistent_connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning('provider is unnecessary when using network_cli and will be ignored') diff --git a/lib/ansible/plugins/action/edgeos_config.py b/lib/ansible/plugins/action/edgeos_config.py index 22ccf5df5a3..0f52d8f9caf 100644 --- a/lib/ansible/plugins/action/edgeos_config.py +++ b/lib/ansible/plugins/action/edgeos_config.py @@ -29,7 +29,8 @@ class ActionModule(ActionNetworkModule): self._config_module = True - if self._play_context.connection != 'network_cli': - return {'failed': True, 'msg': 'Connection type %s is not valid for this module. Must use network_cli.' % self._play_context.connection} + if self._play_context.connection.split('.')[-1] != 'network_cli': + return {'failed': True, 'msg': 'Connection type %s is not valid for this module. Must use fully qualified' + ' name of network_cli connection type.' % self._play_context.connection} return super(ActionModule, self).run(task_vars=task_vars) diff --git a/lib/ansible/plugins/action/enos.py b/lib/ansible/plugins/action/enos.py index 68da7bffa17..ea8a13f508f 100644 --- a/lib/ansible/plugins/action/enos.py +++ b/lib/ansible/plugins/action/enos.py @@ -34,7 +34,8 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'enos_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'enos_config' else False if self._play_context.connection == 'local': provider = load_provider(enos_provider_spec, self._task.args) diff --git a/lib/ansible/plugins/action/eos.py b/lib/ansible/plugins/action/eos.py index 1019d4bbc4e..167319ea0b5 100644 --- a/lib/ansible/plugins/action/eos.py +++ b/lib/ansible/plugins/action/eos.py @@ -38,8 +38,9 @@ class ActionModule(ActionNetworkModule): module_name = self._task.action.split('.')[-1] self._config_module = True if module_name == 'eos_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection in ('network_cli', 'httpapi'): + if persistent_connection in ('network_cli', 'httpapi'): provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning('provider is unnecessary when using %s and will be ignored' % self._play_context.connection) diff --git a/lib/ansible/plugins/action/exos.py b/lib/ansible/plugins/action/exos.py index 7dfebef78c3..b289e521e4c 100644 --- a/lib/ansible/plugins/action/exos.py +++ b/lib/ansible/plugins/action/exos.py @@ -32,12 +32,14 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'exos_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'exos_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection not in ('network_cli', 'httpapi'): + if persistent_connection not in ('network_cli', 'httpapi'): return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection} - if self._play_context.connection == 'network_cli' and self._task.action not in self.EXOS_NETWORK_CLI_MODULES: + if persistent_connection == 'network_cli' and module_name not in self.EXOS_NETWORK_CLI_MODULES: return {'failed': True, 'msg': "Connection type %s is not valid for this module" % self._play_context.connection} return super(ActionModule, self).run(task_vars=task_vars) diff --git a/lib/ansible/plugins/action/ios.py b/lib/ansible/plugins/action/ios.py index 50ebc781426..e14a3cb319e 100644 --- a/lib/ansible/plugins/action/ios.py +++ b/lib/ansible/plugins/action/ios.py @@ -37,8 +37,9 @@ class ActionModule(ActionNetworkModule): module_name = self._task.action.split('.')[-1] self._config_module = True if module_name == 'ios_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection == 'network_cli': + if persistent_connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning('provider is unnecessary when using network_cli and will be ignored') diff --git a/lib/ansible/plugins/action/iosxr.py b/lib/ansible/plugins/action/iosxr.py index c9617cba313..5a007999617 100644 --- a/lib/ansible/plugins/action/iosxr.py +++ b/lib/ansible/plugins/action/iosxr.py @@ -38,6 +38,7 @@ class ActionModule(ActionNetworkModule): module_name = self._task.action.split('.')[-1] self._config_module = True if module_name == 'iosxr_config' else False force_cli = module_name in ('iosxr_netconf', 'iosxr_config', 'iosxr_command', 'iosxr_facts') + persistent_connection = self._play_context.connection.split('.')[-1] if self._play_context.connection == 'local': provider = load_provider(iosxr_provider_spec, self._task.args) @@ -71,8 +72,8 @@ class ActionModule(ActionNetworkModule): 'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'} task_vars['ansible_socket'] = socket_path - elif self._play_context.connection in ('netconf', 'network_cli'): - if force_cli and self._play_context.connection != 'network_cli': + elif persistent_connection in ('netconf', 'network_cli'): + if force_cli and persistent_connection != 'network_cli': return {'failed': True, 'msg': 'Connection type %s is not valid for module %s' % (self._play_context.connection, module_name)} provider = self._task.args.get('provider', {}) diff --git a/lib/ansible/plugins/action/ironware.py b/lib/ansible/plugins/action/ironware.py index a76ae74a405..f8dde23d3df 100644 --- a/lib/ansible/plugins/action/ironware.py +++ b/lib/ansible/plugins/action/ironware.py @@ -35,9 +35,11 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'ironware_config' else False + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'ironware_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection == 'network_cli': + if persistent_connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning('provider is unnecessary when using network_cli and will be ignored') diff --git a/lib/ansible/plugins/action/junos.py b/lib/ansible/plugins/action/junos.py index 385d4899c3e..c46f8a3afc3 100644 --- a/lib/ansible/plugins/action/junos.py +++ b/lib/ansible/plugins/action/junos.py @@ -39,6 +39,7 @@ class ActionModule(ActionNetworkModule): module_name = self._task.action.split('.')[-1] self._config_module = True if module_name == 'junos_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] if self._play_context.connection == 'local': provider = load_provider(junos_provider_spec, self._task.args) @@ -76,7 +77,7 @@ class ActionModule(ActionNetworkModule): 'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'} task_vars['ansible_socket'] = socket_path - elif self._play_context.connection in ('netconf', 'network_cli'): + elif persistent_connection in ('netconf', 'network_cli'): provider = self._task.args.get('provider', {}) if any(provider.values()): # for legacy reasons provider value is required for junos_facts(optional) and junos_package @@ -85,8 +86,8 @@ class ActionModule(ActionNetworkModule): 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 module_name not in CLI_SUPPORTED_MODULES) or \ - (self._play_context.connection == 'netconf' and module_name in CLI_SUPPORTED_MODULES[0:2]): + if (persistent_connection == 'network_cli' and module_name not in CLI_SUPPORTED_MODULES) or \ + (persistent_connection == 'netconf' and module_name in CLI_SUPPORTED_MODULES[0:2]): return {'failed': True, 'msg': "Connection type '%s' is not valid for '%s' module. " "Please see https://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html" % (self._play_context.connection, module_name)} diff --git a/lib/ansible/plugins/action/net_get.py b/lib/ansible/plugins/action/net_get.py index a33f3c46353..b19c44824cf 100644 --- a/lib/ansible/plugins/action/net_get.py +++ b/lib/ansible/plugins/action/net_get.py @@ -37,15 +37,16 @@ class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): socket_path = None - play_context = copy.deepcopy(self._play_context) - play_context.network_os = self._get_network_os(task_vars) + network_os = self._get_network_os(task_vars) + persistent_connection = self._play_context.connection.split('.')[-1] result = super(ActionModule, self).run(task_vars=task_vars) - if play_context.connection != 'network_cli': + if persistent_connection != 'network_cli': # It is supported only with network_cli result['failed'] = True - result['msg'] = ('please use network_cli connection type for net_get module') + result['msg'] = ('connection type %s is not valid for net_get module,' + ' please use fully qualified name of network_cli connection type' % self._play_context.connection) return result try: diff --git a/lib/ansible/plugins/action/net_put.py b/lib/ansible/plugins/action/net_put.py index dd4b850e68d..bd844a12166 100644 --- a/lib/ansible/plugins/action/net_put.py +++ b/lib/ansible/plugins/action/net_put.py @@ -36,15 +36,16 @@ class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): socket_path = None - play_context = copy.deepcopy(self._play_context) - play_context.network_os = self._get_network_os(task_vars) + network_os = self._get_network_os(task_vars).split('.')[-1] + persistent_connection = self._play_context.connection.split('.')[-1] result = super(ActionModule, self).run(task_vars=task_vars) - if play_context.connection != 'network_cli': + if persistent_connection != 'network_cli': # It is supported only with network_cli result['failed'] = True - result['msg'] = ('please use network_cli connection type for net_put module') + result['msg'] = ('connection type %s is not valid for net_put module,' + ' please use fully qualified name of network_cli connection type' % self._play_context.connection) return result try: @@ -115,7 +116,7 @@ class ActionModule(ActionBase): ) except Exception as exc: if to_text(exc) == "No response from server": - if play_context.network_os == 'iosxr': + if network_os == 'iosxr': # IOSXR sometimes closes socket prematurely after completion # of file transfer result['msg'] = 'Warning: iosxr scp server pre close issue. Please check dest' diff --git a/lib/ansible/plugins/action/netconf.py b/lib/ansible/plugins/action/netconf.py index 9c0510b4650..369c66ff155 100644 --- a/lib/ansible/plugins/action/netconf.py +++ b/lib/ansible/plugins/action/netconf.py @@ -35,11 +35,12 @@ class ActionModule(ActionNetworkModule): module_name = self._task.action.split('.')[-1] self._config_module = True if module_name == 'netconf_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection not in ['netconf', 'local'] and module_name == 'netconf_config': + if persistent_connection not in ['netconf', 'local'] and module_name == 'netconf_config': return {'failed': True, 'msg': 'Connection type %s is not valid for netconf_config module. ' 'Valid connection type is netconf or local (deprecated)' % self._play_context.connection} - elif self._play_context.connection not in ['netconf'] and module_name != 'netconf_config': + elif persistent_connection not in ['netconf'] and module_name != 'netconf_config': return {'failed': True, 'msg': 'Connection type %s is not valid for %s module. ' 'Valid connection type is netconf.' % (self._play_context.connection, module_name)} diff --git a/lib/ansible/plugins/action/nxos.py b/lib/ansible/plugins/action/nxos.py index fb634b15586..93445d60a0b 100644 --- a/lib/ansible/plugins/action/nxos.py +++ b/lib/ansible/plugins/action/nxos.py @@ -39,9 +39,9 @@ class ActionModule(ActionNetworkModule): module_name = self._task.action.split('.')[-1] self._config_module = True if module_name == 'nxos_config' else False - socket_path = None + persistent_connection = self._play_context.connection.split('.')[-1] - if (self._play_context.connection == 'httpapi' or self._task.args.get('provider', {}).get('transport') == 'nxapi') \ + if (persistent_connection == 'httpapi' or self._task.args.get('provider', {}).get('transport') == 'nxapi') \ and module_name in ('nxos_file_copy', 'nxos_nxapi'): return {'failed': True, 'msg': "Transport type 'nxapi' is not valid for '%s' module." % (module_name)} @@ -71,7 +71,7 @@ class ActionModule(ActionNetworkModule): msg += ' Current persistent_connect_timeout setting:' + str(persistent_connect_timeout) return {'failed': True, 'msg': msg} - if self._play_context.connection in ('network_cli', 'httpapi'): + if persistent_connection in ('network_cli', 'httpapi'): provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning('provider is unnecessary when using %s and will be ignored' % self._play_context.connection) diff --git a/lib/ansible/plugins/action/nxos_file_copy.py b/lib/ansible/plugins/action/nxos_file_copy.py index 2d96ae6d6ea..5722106a20f 100644 --- a/lib/ansible/plugins/action/nxos_file_copy.py +++ b/lib/ansible/plugins/action/nxos_file_copy.py @@ -466,10 +466,10 @@ class ActionModule(ActionBase): self.play_context = copy.deepcopy(self._play_context) self.results = super(ActionModule, self).run(task_vars=task_vars) - if self.play_context.connection != 'network_cli': + if self.play_context.connection.split('.')[-1] != 'network_cli': # Plugin is supported only with network_cli self.results['failed'] = True - self.results['msg'] = ('Connection type must be ') + self.results['msg'] = 'Connection type must be fully qualified name for network_cli connection type, got %s' % self.play_context.connection return self.results # Get playbook values diff --git a/lib/ansible/plugins/action/slxos.py b/lib/ansible/plugins/action/slxos.py index 9259b6c3d66..1cf3ccdbdad 100644 --- a/lib/ansible/plugins/action/slxos.py +++ b/lib/ansible/plugins/action/slxos.py @@ -31,7 +31,10 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'slxos_config' else False - if self._play_context.connection not in ('network_cli'): + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'slxos_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] + + if persistent_connection not in ('network_cli'): return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection} return super(ActionModule, self).run(task_vars=task_vars) diff --git a/lib/ansible/plugins/action/sros.py b/lib/ansible/plugins/action/sros.py index e7af522bb72..a86baa8ac62 100644 --- a/lib/ansible/plugins/action/sros.py +++ b/lib/ansible/plugins/action/sros.py @@ -36,8 +36,11 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'sros_config' else False - if self._play_context.connection == 'network_cli': + module_name = self._task.action.split('.')[-1] + persistent_connection = self._play_context.connection.split('.')[-1] + + self._config_module = True if module_name == 'sros_config' else False + if persistent_connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning('provider is unnecessary when using network_cli and will be ignored') diff --git a/lib/ansible/plugins/action/voss.py b/lib/ansible/plugins/action/voss.py index 562b8734d63..024987bf278 100644 --- a/lib/ansible/plugins/action/voss.py +++ b/lib/ansible/plugins/action/voss.py @@ -27,7 +27,10 @@ class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): del tmp # tmp no longer has any effect - self._config_module = True if self._task.action == 'voss_config' else False - if self._play_context.connection not in ('network_cli'): + module_name = self._task.action.split('.')[-1] + self._config_module = True if module_name == 'voss_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] + + if persistent_connection not in ('network_cli'): return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection} return super(ActionModule, self).run(task_vars=task_vars) diff --git a/lib/ansible/plugins/action/vyos.py b/lib/ansible/plugins/action/vyos.py index c7a8a732971..d0e13b8d552 100644 --- a/lib/ansible/plugins/action/vyos.py +++ b/lib/ansible/plugins/action/vyos.py @@ -37,8 +37,9 @@ class ActionModule(ActionNetworkModule): module_name = self._task.action.split('.')[-1] self._config_module = True if module_name == 'vyos_config' else False + persistent_connection = self._play_context.connection.split('.')[-1] - if self._play_context.connection == 'network_cli': + if persistent_connection == 'network_cli': provider = self._task.args.get('provider', {}) if any(provider.values()): display.warning('provider is unnecessary when using network_cli and will be ignored')