mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make sure includes for handlers in roles look in the correct subdir
This commit is contained in:
parent
64a8d24b72
commit
daf6eb97d3
1 changed files with 6 additions and 6 deletions
|
@ -144,6 +144,9 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
|
||||||
cumulative_path = None
|
cumulative_path = None
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
|
subdir = 'tasks'
|
||||||
|
if use_handlers:
|
||||||
|
subdir = 'handlers'
|
||||||
while parent_include is not None:
|
while parent_include is not None:
|
||||||
if not isinstance(parent_include, TaskInclude):
|
if not isinstance(parent_include, TaskInclude):
|
||||||
parent_include = parent_include._parent
|
parent_include = parent_include._parent
|
||||||
|
@ -155,8 +158,8 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
|
||||||
cumulative_path = os.path.join(parent_include_dir, cumulative_path)
|
cumulative_path = os.path.join(parent_include_dir, cumulative_path)
|
||||||
include_target = templar.template(t.args['_raw_params'])
|
include_target = templar.template(t.args['_raw_params'])
|
||||||
if t._role:
|
if t._role:
|
||||||
new_basedir = os.path.join(t._role._role_path, 'tasks', cumulative_path)
|
new_basedir = os.path.join(t._role._role_path, subdir, cumulative_path)
|
||||||
include_file = loader.path_dwim_relative(new_basedir, 'tasks', include_target)
|
include_file = loader.path_dwim_relative(new_basedir, subdir, include_target)
|
||||||
else:
|
else:
|
||||||
include_file = loader.path_dwim_relative(loader.get_basedir(), cumulative_path, include_target)
|
include_file = loader.path_dwim_relative(loader.get_basedir(), cumulative_path, include_target)
|
||||||
|
|
||||||
|
@ -179,10 +182,7 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
|
||||||
suppress_extended_error=True,
|
suppress_extended_error=True,
|
||||||
)
|
)
|
||||||
if t._role:
|
if t._role:
|
||||||
if use_handlers:
|
include_file = loader.path_dwim_relative(t._role._role_path, subdir, include_target)
|
||||||
include_file = loader.path_dwim_relative(t._role._role_path, 'handlers', include_target)
|
|
||||||
else:
|
|
||||||
include_file = loader.path_dwim_relative(t._role._role_path, 'tasks', include_target)
|
|
||||||
else:
|
else:
|
||||||
include_file = loader.path_dwim(include_target)
|
include_file = loader.path_dwim(include_target)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue