fixed lookup search path (#16630)

* fixed lookup search path

added ansible_search_path var that contains the proper list and in order
removed roledir var which was only used by first_found, rest used role_path
added needle function for lookups that mirrors the action plugin one, now
both types of plugins use same pathing.

* added missing os import

* renamed as per feedback

* fixed missing rename in first_found

* also fixed first_found

* fixed import to match new error class

* fixed getattr ref
This commit is contained in:
Brian Coca 2016-07-13 10:06:34 -04:00 committed by GitHub
parent 221520cbad
commit 3c39bb5633
11 changed files with 87 additions and 84 deletions

View file

@ -831,18 +831,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
to get back the first existing file found.
'''
path_stack = []
dep_chain = self._task._block.get_dep_chain()
# inside role: add the dependency chain
if dep_chain:
path_stack.extend(reversed([x._role_path for x in dep_chain]))
task_dir = os.path.dirname(self._task.get_path())
# include from diff directory: add it to file path
if not task_dir.endswith('tasks') and task_dir != self._loader.get_basedir():
path_stack.append(task_dir)
path_stack = self._task.get_search_path()
result = self._loader.path_dwim_relative_stack(path_stack, dirname, needle)