From 06b072c1f7daca45fb205c6085f5662cf7f33971 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Sat, 13 Feb 2016 01:02:47 -0500 Subject: [PATCH] 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 --- lib/ansible/playbook/block.py | 7 +++++-- lib/ansible/plugins/strategy/__init__.py | 8 ++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/ansible/playbook/block.py b/lib/ansible/playbook/block.py index b16316ab2e..1c9569de8d 100644 --- a/lib/ansible/playbook/block.py +++ b/lib/ansible/playbook/block.py @@ -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) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 49c1bdfb35..29d6780876 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -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())