fixing bug with role paths

pull/9968/head
James Cammarata 10 years ago
parent fd67a20787
commit 0823fb2cd9

@ -38,8 +38,9 @@ class RoleDefinition(Base, Conditional, Taggable):
_role = FieldAttribute(isa='string')
def __init__(self, role_path=None):
self._role_path = role_path
def __init__(self, role_basedir=None):
self._role_path = None
self._role_basedir = role_basedir
self._role_params = dict()
super(RoleDefinition, self).__init__()
@ -112,9 +113,6 @@ class RoleDefinition(Base, Conditional, Taggable):
'''
# FIXME: this should use unfrackpath once the utils code has been sorted out
if self._role_path:
role_path = self._role_path
else:
role_path = os.path.normpath(role_name)
if self._loader.path_exists(role_path):
@ -122,7 +120,11 @@ class RoleDefinition(Base, Conditional, Taggable):
return (role_name, role_path)
else:
# FIXME: this should search in the configured roles path
for path in (os.path.join(self._loader.get_basedir(), 'roles'), './roles', '/etc/ansible/roles'):
role_search_paths = [os.path.join(self._loader.get_basedir(), 'roles'), './roles', '/etc/ansible/roles']
if self._role_basedir:
role_search_paths = [self._role_basedir] + role_search_paths
for path in role_search_paths:
role_path = os.path.join(path, role_name)
if self._loader.path_exists(role_path):
return (role_name, role_path)
@ -131,7 +133,6 @@ class RoleDefinition(Base, Conditional, Taggable):
# in the yaml so the error line/file can be reported
# here
#import epdb; epdb.st()
raise AnsibleError("the role '%s' was not found" % role_name)
def _split_role_params(self, ds):

@ -37,13 +37,13 @@ class RoleInclude(RoleDefinition):
FIXME: docstring
"""
def __init__(self, role_path=None):
super(RoleInclude, self).__init__(role_path=role_path)
def __init__(self, role_basedir=None):
super(RoleInclude, self).__init__(role_basedir=role_basedir)
@staticmethod
def load(data, current_role_path=None, parent_role=None, variable_manager=None, loader=None):
assert isinstance(data, string_types) or isinstance(data, dict)
ri = RoleInclude(role_path=current_role_path)
ri = RoleInclude(role_basedir=current_role_path)
return ri.load_data(data, variable_manager=variable_manager, loader=loader)

Loading…
Cancel
Save