Fixing parentage of include_role objects for param inheritance

Fixes #17686
pull/17598/merge
James Cammarata 8 years ago
parent 6be2f0bded
commit e4ee9de3f4

@ -68,9 +68,8 @@ class IncludeRole(Task):
ri = RoleInclude.load(self.name, play=myplay, variable_manager=variable_manager, loader=loader)
ri.vars.update(self.vars)
#ri._role_params.update(self.args) # jimi-c cant we avoid this?
#build role
# build role
actual_role = Role.load(ri, myplay, parent_role=self._parent_role, from_files=self._from_files)
# compile role
@ -78,7 +77,7 @@ class IncludeRole(Task):
# set parent to ensure proper inheritance
for b in blocks:
b._parent = self._parent
b._parent = self
# updated available handlers in play
myplay.handlers = myplay.handlers + actual_role.get_handler_blocks(play=myplay)
@ -108,8 +107,13 @@ class IncludeRole(Task):
new_me = super(IncludeRole, self).copy(exclude_parent=exclude_parent, exclude_tasks=exclude_tasks)
new_me.statically_loaded = self.statically_loaded
new_me.name = self.name
new_me._from_files = self._from_files.copy()
new_me._parent_role = self._parent_role
return new_me
def get_include_params(self):
v = super(IncludeRole, self).get_include_params()
if self._parent_role:
v.update(self._parent_role.get_role_params())
return v

@ -318,7 +318,7 @@ class Task(Base, Conditional, Taggable, Become):
all_vars = dict()
if self._parent:
all_vars.update(self._parent.get_include_params())
if self.action == 'include':
if self.action in ('include', 'include_role'):
all_vars.update(self.vars)
return all_vars

Loading…
Cancel
Save