From d4c63e3300e8d081332ec7018ce314036c4c8993 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Thu, 20 Dec 2012 14:17:12 +0100 Subject: [PATCH] Ensure each basedir is only added to the search path once Fixes #1790. --- lib/ansible/utils/plugins.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/ansible/utils/plugins.py b/lib/ansible/utils/plugins.py index 50815e6668..3a6d9947a9 100644 --- a/lib/ansible/utils/plugins.py +++ b/lib/ansible/utils/plugins.py @@ -58,10 +58,15 @@ class PluginLoader(object): """Return a list of paths to search for plugins in The list is searched in order.""" - return self._extra_dirs + \ - [os.path.join(basedir, self.subdir) for basedir in _basedirs] + \ - self.config.split(os.pathsep) + \ - self._get_package_path() + ret = [] + ret += self._extra_dirs + for basedir in _basedirs: + fullpath = os.path.join(basedir, self.subdir) + if fullpath not in ret: + ret.append(fullpath) + ret += self.config.split(os.pathsep) + ret += self._get_package_path() + return ret def add_directory(self, directory): """Adds an additional directory to the search path"""