|
|
@ -152,10 +152,10 @@ class Play(object):
|
|
|
|
if level > 20:
|
|
|
|
if level > 20:
|
|
|
|
raise errors.AnsibleError("too many levels of recursion while resolving role dependencies")
|
|
|
|
raise errors.AnsibleError("too many levels of recursion while resolving role dependencies")
|
|
|
|
for role in roles:
|
|
|
|
for role in roles:
|
|
|
|
path,role_vars = self._get_role_path(role)
|
|
|
|
role_path,role_vars = self._get_role_path(role)
|
|
|
|
# the meta directory contains the yaml that should
|
|
|
|
# the meta directory contains the yaml that should
|
|
|
|
# hold the list of dependencies (if any)
|
|
|
|
# hold the list of dependencies (if any)
|
|
|
|
meta = self._resolve_main(utils.path_dwim(self.basedir, os.path.join(path, 'meta')))
|
|
|
|
meta = self._resolve_main(utils.path_dwim(self.basedir, os.path.join(role_path, 'meta')))
|
|
|
|
if os.path.isfile(meta):
|
|
|
|
if os.path.isfile(meta):
|
|
|
|
data = utils.parse_yaml_from_file(meta)
|
|
|
|
data = utils.parse_yaml_from_file(meta)
|
|
|
|
if data:
|
|
|
|
if data:
|
|
|
@ -169,11 +169,11 @@ class Play(object):
|
|
|
|
if 'role' in dep_vars:
|
|
|
|
if 'role' in dep_vars:
|
|
|
|
del dep_vars['role']
|
|
|
|
del dep_vars['role']
|
|
|
|
self._build_role_dependencies([dep], dep_stack, vars=dep_vars, level=level+1)
|
|
|
|
self._build_role_dependencies([dep], dep_stack, vars=dep_vars, level=level+1)
|
|
|
|
dep_stack.append([dep,dep_vars])
|
|
|
|
dep_stack.append([dep,dep_path,dep_vars])
|
|
|
|
# only add the current role when we're at the top level,
|
|
|
|
# only add the current role when we're at the top level,
|
|
|
|
# otherwise we'll end up in a recursive loop
|
|
|
|
# otherwise we'll end up in a recursive loop
|
|
|
|
if level == 0:
|
|
|
|
if level == 0:
|
|
|
|
dep_stack.append([role,role_vars])
|
|
|
|
dep_stack.append([role,role_path,role_vars])
|
|
|
|
return dep_stack
|
|
|
|
return dep_stack
|
|
|
|
|
|
|
|
|
|
|
|
def _load_roles(self, roles, ds):
|
|
|
|
def _load_roles(self, roles, ds):
|
|
|
@ -204,9 +204,7 @@ class Play(object):
|
|
|
|
|
|
|
|
|
|
|
|
roles = self._build_role_dependencies(roles, [], self.vars)
|
|
|
|
roles = self._build_role_dependencies(roles, [], self.vars)
|
|
|
|
|
|
|
|
|
|
|
|
for role,role_vars in roles:
|
|
|
|
for role,role_path,role_vars in roles:
|
|
|
|
path,ignore = self._get_role_path(role)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# special vars must be extracted from the dict to the included tasks
|
|
|
|
# special vars must be extracted from the dict to the included tasks
|
|
|
|
special_keys = [ "sudo", "sudo_user", "when", "with_items" ]
|
|
|
|
special_keys = [ "sudo", "sudo_user", "when", "with_items" ]
|
|
|
|
special_vars = {}
|
|
|
|
special_vars = {}
|
|
|
@ -214,17 +212,17 @@ class Play(object):
|
|
|
|
if k in role_vars:
|
|
|
|
if k in role_vars:
|
|
|
|
special_vars[k] = role_vars[k]
|
|
|
|
special_vars[k] = role_vars[k]
|
|
|
|
|
|
|
|
|
|
|
|
task_basepath = utils.path_dwim(self.basedir, os.path.join(path, 'tasks'))
|
|
|
|
task_basepath = utils.path_dwim(self.basedir, os.path.join(role_path, 'tasks'))
|
|
|
|
handler_basepath = utils.path_dwim(self.basedir, os.path.join(path, 'handlers'))
|
|
|
|
handler_basepath = utils.path_dwim(self.basedir, os.path.join(role_path, 'handlers'))
|
|
|
|
vars_basepath = utils.path_dwim(self.basedir, os.path.join(path, 'vars'))
|
|
|
|
vars_basepath = utils.path_dwim(self.basedir, os.path.join(role_path, 'vars'))
|
|
|
|
|
|
|
|
|
|
|
|
task = self._resolve_main(task_basepath)
|
|
|
|
task = self._resolve_main(task_basepath)
|
|
|
|
handler = self._resolve_main(handler_basepath)
|
|
|
|
handler = self._resolve_main(handler_basepath)
|
|
|
|
vars_file = self._resolve_main(vars_basepath)
|
|
|
|
vars_file = self._resolve_main(vars_basepath)
|
|
|
|
library = utils.path_dwim(self.basedir, os.path.join(path, 'library'))
|
|
|
|
library = utils.path_dwim(self.basedir, os.path.join(role_path, 'library'))
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.isfile(task) and not os.path.isfile(handler) and not os.path.isfile(vars_file) and not os.path.isdir(library):
|
|
|
|
if not os.path.isfile(task) and not os.path.isfile(handler) and not os.path.isfile(vars_file) and not os.path.isdir(library):
|
|
|
|
raise errors.AnsibleError("found role at %s, but cannot find %s or %s or %s or %s" % (path, task, handler, vars_file, library))
|
|
|
|
raise errors.AnsibleError("found role at %s, but cannot find %s or %s or %s or %s" % (role_path, task, handler, vars_file, library))
|
|
|
|
if os.path.isfile(task):
|
|
|
|
if os.path.isfile(task):
|
|
|
|
nt = dict(include=pipes.quote(task), vars=role_vars)
|
|
|
|
nt = dict(include=pipes.quote(task), vars=role_vars)
|
|
|
|
for k in special_keys:
|
|
|
|
for k in special_keys:
|
|
|
|