Fix bugs related to task_includes and dep chain inheritance

* Fix the way task_include fields were created and copied
* Have blocks get_dep_chain() look at task_include's blocks for proper
  dep chain inheritance
* Fix the way task_include fields are copied to prevent a recursive
  degradation

Fixes #14460
pull/14334/merge
James Cammarata 9 years ago
parent 22aaff5af7
commit 06b072c1f7

@ -153,6 +153,8 @@ class Block(Base, Become, Conditional, Taggable):
if self._dep_chain is None:
if self._parent_block:
return self._parent_block.get_dep_chain()
elif self._task_include:
return self._task_include._block.get_dep_chain()
else:
return None
else:
@ -193,7 +195,8 @@ class Block(Base, Become, Conditional, Taggable):
new_me._task_include = None
if self._task_include:
new_me._task_include = self._task_include.copy()
new_me._task_include = self._task_include.copy(exclude_block=True)
new_me._task_include._block = self._task_include._block.copy(exclude_tasks=True)
return new_me
@ -374,7 +377,7 @@ class Block(Base, Become, Conditional, Taggable):
return tmp_list
def evaluate_block(block):
new_block = self.copy()
new_block = self.copy(exclude_tasks=True)
new_block.block = evaluate_and_append_task(block.block)
new_block.rescue = evaluate_and_append_task(block.rescue)
new_block.always = evaluate_and_append_task(block.always)

@ -452,7 +452,7 @@ class StrategyBase:
block_list = load_list_of_blocks(
data,
play=included_file._task._block._play,
parent_block=included_file._task._block,
parent_block=None,
task_include=included_file._task,
role=included_file._task._role,
use_handlers=is_handler,
@ -478,11 +478,7 @@ class StrategyBase:
# set the vars for this task from those specified as params to the include
for b in block_list:
# first make a copy of the including task, so that each has a unique copy to modify
# FIXME: not sure if this is the best way to fix this, as we might be losing
# information in the copy. Previously we assigned the include params to
# the block variables directly, which caused other problems, so we may
# need to figure out a third option if this also presents problems.
b._task_include = b._task_include.copy(exclude_block=True)
b._task_include = b._task_include.copy()
# then we create a temporary set of vars to ensure the variable reference is unique
temp_vars = b._task_include.vars.copy()
temp_vars.update(included_file._args.copy())

Loading…
Cancel
Save