diff --git a/lib/ansible/playbook/role/__init__.py b/lib/ansible/playbook/role/__init__.py index 133dd50acca..b86ad0fd024 100644 --- a/lib/ansible/playbook/role/__init__.py +++ b/lib/ansible/playbook/role/__init__.py @@ -252,10 +252,13 @@ class Role(Base, Become, Conditional, Taggable): def get_parents(self): return self._parents - def get_default_vars(self): + def get_default_vars(self, dep_chain=[]): default_vars = dict() for dep in self.get_all_dependencies(): default_vars = combine_vars(default_vars, dep.get_default_vars()) + if dep_chain: + for parent in dep_chain: + default_vars = combine_vars(default_vars, parent._default_vars) default_vars = combine_vars(default_vars, self._default_vars) return default_vars diff --git a/lib/ansible/vars/__init__.py b/lib/ansible/vars/__init__.py index 2d1a872f294..c95d25c5a32 100644 --- a/lib/ansible/vars/__init__.py +++ b/lib/ansible/vars/__init__.py @@ -220,7 +220,7 @@ class VariableManager: # sure it sees its defaults above any other roles, as we previously # (v1) made sure each task had a copy of its roles default vars if task and task._role is not None: - all_vars = combine_vars(all_vars, task._role.get_default_vars()) + all_vars = combine_vars(all_vars, task._role.get_default_vars(dep_chain=task._block._dep_chain)) if host: # next, if a host is specified, we load any vars from group_vars