summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2016-10-05 01:24:23 -0500
committerJames Cammarata <jimi@sngx.net>2016-10-05 01:26:00 -0500
commita7d0cc6e611d79adf3286ae98638f99050d08c35 (patch)
treeea8be48c8566c77a3842772b65243bb3d7612bc1
parentea5e2d46ee21f14e88de25a843177dd5ffb6af32 (diff)
downloadansible-a7d0cc6e611d79adf3286ae98638f99050d08c35.tar.gz
Move searching for roles in the cur basedir to last
Searching the DEFAULT_ROLES_PATH and the roles basedir should come before this, and it has been a long standing oversight. Fixes #17882 (cherry picked from commit 0a86ddc25125359c244ac7040036a5080dd5bb04)
-rw-r--r--lib/ansible/playbook/role/definition.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/ansible/playbook/role/definition.py b/lib/ansible/playbook/role/definition.py
index de527d5698..817e32ea3d 100644
--- a/lib/ansible/playbook/role/definition.py
+++ b/lib/ansible/playbook/role/definition.py
@@ -138,18 +138,22 @@ class RoleDefinition(Base, Become, Conditional, Taggable):
# 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'),
- self._loader.get_basedir(),
]
# also search in the configured roles path
if C.DEFAULT_ROLES_PATH:
role_search_paths.extend(C.DEFAULT_ROLES_PATH)
- # finally, append the roles basedir, if it was set, so we can
+ # next, append the roles basedir, if it was set, so we can
# search relative to that directory for dependent roles
if self._role_basedir:
role_search_paths.append(self._role_basedir)
+ # finally as a last resort we look in the current basedir as set
+ # in the loader (which should be the playbook dir itself) but without
+ # the roles/ dir appended
+ role_search_paths.append(self._loader.get_basedir())
+
# create a templar class to template the dependency names, in
# case they contain variables
if self._variable_manager is not None: