mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 20:31:27 -07:00
ensure inventory plugin loading rel to play (#51177)
Ensure inventory plugin loading rel to play fixes #51033 * clarify paths * now adding dirs funciton in loader * better warnings * each cli should handle adding dirs depending on context
This commit is contained in:
parent
66493e47cf
commit
780ee45819
8 changed files with 196 additions and 2 deletions
|
@ -51,7 +51,7 @@ def add_all_plugin_dirs(path):
|
|||
if os.path.isdir(plugin_path):
|
||||
obj.add_directory(to_text(plugin_path))
|
||||
else:
|
||||
display.warning("Ignoring invalid path provided to plugin path: %s is not a directory" % to_native(path))
|
||||
display.warning("Ignoring invalid path provided to plugin path: '%s' is not a directory" % to_native(path))
|
||||
|
||||
|
||||
def get_shell_plugin(shell_type=None, executable=None):
|
||||
|
@ -87,6 +87,13 @@ def get_shell_plugin(shell_type=None, executable=None):
|
|||
return shell
|
||||
|
||||
|
||||
def add_dirs_to_loader(which_loader, paths):
|
||||
|
||||
loader = getattr(sys.modules[__name__], '%s_loader' % which_loader)
|
||||
for path in paths:
|
||||
loader.add_directory(path, with_subdir=True)
|
||||
|
||||
|
||||
class PluginLoader:
|
||||
'''
|
||||
PluginLoader loads plugins from the configured plugin directories.
|
||||
|
@ -435,6 +442,7 @@ class PluginLoader:
|
|||
# looks like _get_paths() never forces a cache refresh so if we expect
|
||||
# additional directories to be added later, it is buggy.
|
||||
for path in (p for p in self._get_paths() if p not in self._searched_paths and os.path.isdir(p)):
|
||||
display.debug('trying %s' % path)
|
||||
try:
|
||||
full_paths = (os.path.join(path, f) for f in os.listdir(path))
|
||||
except OSError as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue