diff options
author | James Cammarata <jimi@sngx.net> | 2016-02-13 01:02:47 -0500 |
---|---|---|
committer | James Cammarata <jimi@sngx.net> | 2016-02-13 01:09:16 -0500 |
commit | 028c710380c2d76566c81efe514edc93ccf01f47 (patch) | |
tree | 50e26b4c8c4c6a0e13d1df9fb830fa85235d7642 | |
parent | 8ee8872d6b7d34cbee4704d07743632cb616fb66 (diff) | |
download | ansible-028c710380c2d76566c81efe514edc93ccf01f47.tar.gz |
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
-rw-r--r-- | lib/ansible/playbook/block.py | 7 | ||||
-rw-r--r-- | 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 52f1e588cc..dd1a46e5c4 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()) |