mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
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:
parent
221520cbad
commit
3c39bb5633
11 changed files with 87 additions and 84 deletions
|
@ -19,6 +19,8 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
|
||||
from ansible.compat.six import iteritems, string_types
|
||||
|
||||
from ansible.errors import AnsibleError, AnsibleParserError
|
||||
|
@ -454,3 +456,24 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
|
||||
def _get_attr_loop_control(self):
|
||||
return self._attributes['loop_control']
|
||||
|
||||
|
||||
def get_search_path(self):
|
||||
'''
|
||||
Return the list of paths you should search for files, in order.
|
||||
This follows role/playbook dependency chain.
|
||||
'''
|
||||
path_stack = []
|
||||
|
||||
dep_chain = self._block.get_dep_chain()
|
||||
# inside role: add the dependency chain from current to dependant
|
||||
if dep_chain:
|
||||
path_stack.extend(reversed([x._role_path for x in dep_chain]))
|
||||
|
||||
# add path of task itself, unless it is already in the list
|
||||
task_dir = os.path.dirname(self.get_path())
|
||||
if task_dir not in path_stack:
|
||||
path_stack.append(task_dir)
|
||||
|
||||
return path_stack
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue