From f2b853f7a07358908d56ed36a5af3b5dc09a2735 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 1 Dec 2014 17:36:57 -0500 Subject: [PATCH] changed plugin load priority to be path based, not suffix based. --- lib/ansible/utils/plugins.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/ansible/utils/plugins.py b/lib/ansible/utils/plugins.py index 1955ade2379..29771d0ed97 100644 --- a/lib/ansible/utils/plugins.py +++ b/lib/ansible/utils/plugins.py @@ -167,17 +167,20 @@ class PluginLoader(object): else: suffixes = ['.py', ''] - for suffix in suffixes: - full_name = '%s%s' % (name, suffix) - if full_name in self._plugin_path_cache: - return self._plugin_path_cache[full_name] + # loop over paths and then loop over suffixes to find plugin + for i in self._get_paths(): + for suffix in suffixes: + full_name = '%s%s' % (name, suffix) + + if full_name in self._plugin_path_cache: + return self._plugin_path_cache[full_name] - for i in self._get_paths(): path = os.path.join(i, full_name) if os.path.isfile(path): self._plugin_path_cache[full_name] = path return path + # if nothing is found, try finding alias/deprecated if not name.startswith('_'): return self.find_plugin('_' + name, suffixes, transport)