From e4ee9de3f4fd77f8d445724b170a2854efcf68c1 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 30 Sep 2016 16:05:43 -0500 Subject: [PATCH] Fixing parentage of include_role objects for param inheritance Fixes #17686 --- lib/ansible/playbook/role_include.py | 12 ++++++++---- lib/ansible/playbook/task.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ansible/playbook/role_include.py b/lib/ansible/playbook/role_include.py index 490d74d7450..8c0d75b88c5 100644 --- a/lib/ansible/playbook/role_include.py +++ b/lib/ansible/playbook/role_include.py @@ -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 diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index e78b04e5d8a..2d98f750464 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -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