Make default var lookup for tasks follow the dep chain
Related to #14296 (@jjshoe's follow-up example on that issue)
This commit is contained in:
parent
e11446490e
commit
f427955640
2 changed files with 5 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue