mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
corrected role path search order
the unfraking was matching roles in current dir as it always returns a full path, pushed to the bottom as match of last resort fixes #13645
This commit is contained in:
parent
010839aedc
commit
202b92179d
1 changed files with 34 additions and 36 deletions
|
@ -135,18 +135,10 @@ class RoleDefinition(Base, Become, Conditional, Taggable):
|
|||
append it to the default role path
|
||||
'''
|
||||
|
||||
role_path = unfrackpath(role_name)
|
||||
|
||||
if self._loader.path_exists(role_path):
|
||||
role_name = os.path.basename(role_name)
|
||||
return (role_name, role_path)
|
||||
else:
|
||||
# we always start the search for roles in the base directory of the playbook
|
||||
role_search_paths = [
|
||||
os.path.join(self._loader.get_basedir(), u'roles'),
|
||||
u'./roles',
|
||||
self._loader.get_basedir(),
|
||||
u'./'
|
||||
]
|
||||
|
||||
# also search in the configured roles path
|
||||
|
@ -176,6 +168,12 @@ class RoleDefinition(Base, Become, Conditional, Taggable):
|
|||
if self._loader.path_exists(role_path):
|
||||
return (role_name, role_path)
|
||||
|
||||
# if not found elsewhere try to extract path from name
|
||||
role_path = unfrackpath(role_name)
|
||||
if self._loader.path_exists(role_path):
|
||||
role_name = os.path.basename(role_name)
|
||||
return (role_name, role_path)
|
||||
|
||||
raise AnsibleError("the role '%s' was not found in %s" % (role_name, ":".join(role_search_paths)), obj=self._ds)
|
||||
|
||||
def _split_role_params(self, ds):
|
||||
|
|
Loading…
Reference in a new issue