summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/plugins/__init__.py')
-rw-r--r--lib/ansible/plugins/__init__.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/ansible/plugins/__init__.py b/lib/ansible/plugins/__init__.py
index 25152bfc00..a6414a43da 100644
--- a/lib/ansible/plugins/__init__.py
+++ b/lib/ansible/plugins/__init__.py
@@ -31,6 +31,7 @@ import warnings
from collections import defaultdict
from ansible import constants as C
+from ansible.compat.six import string_types
from ansible.module_utils._text import to_text
@@ -161,7 +162,7 @@ class PluginLoader:
self.package_path = os.path.dirname(m.__file__)
return self._all_directories(self.package_path)
- def _get_paths(self):
+ def _get_paths(self, subdirs=True):
''' Return a list of paths to search for plugins in '''
if self._paths is not None:
@@ -173,10 +174,11 @@ class PluginLoader:
if self.config is not None:
for path in self.config:
path = os.path.realpath(os.path.expanduser(path))
- contents = glob.glob("%s/*" % path) + glob.glob("%s/*/*" % path)
- for c in contents:
- if os.path.isdir(c) and c not in ret:
- ret.append(c)
+ if subdirs:
+ contents = glob.glob("%s/*" % path) + glob.glob("%s/*/*" % path)
+ for c in contents:
+ if os.path.isdir(c) and c not in ret:
+ ret.append(c)
if path not in ret:
ret.append(path)
@@ -466,6 +468,13 @@ module_loader = PluginLoader(
'library',
)
+module_utils_loader = PluginLoader(
+ '',
+ 'ansible.module_utils',
+ 'module_utils',
+ 'module_utils',
+)
+
lookup_loader = PluginLoader(
'LookupModule',
'ansible.plugins.lookup',