Skip to content

Instantly share code, notes, and snippets.

@mkrizek
Last active April 13, 2018 19:02
Show Gist options
  • Save mkrizek/c147fb70656f7cd7031f5abcebe1adf0 to your computer and use it in GitHub Desktop.
Save mkrizek/c147fb70656f7cd7031f5abcebe1adf0 to your computer and use it in GitHub Desktop.
diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py
index d9a0c185e8..5a2a9bcc09 100644
--- a/lib/ansible/plugins/strategy/linear.py
+++ b/lib/ansible/plugins/strategy/linear.py
@@ -335,6 +335,24 @@ class StrategyModule(StrategyBase):
else:
new_blocks = self._load_included_file(included_file, iterator=iterator)
+
+ def _create_noop_block(original_block, parent):
+ def create_block(b):
+ tmp = []
+ for el in b:
+ if isinstance(el, Task):
+ tmp.append(noop_task)
+ elif isinstance(el, Block):
+ tmp.append(_create_noop_block(el, el))
+ return tmp
+
+ noop_block = Block(parent_block=parent)
+ noop_block.block = create_block(original_block.block)
+ noop_block.always = create_block(original_block.always)
+ noop_block.rescue = create_block(original_block.rescue)
+
+ return noop_block
+
display.debug("iterating over new_blocks loaded from include file")
for new_block in new_blocks:
task_vars = self._variable_manager.get_vars(
@@ -345,10 +363,7 @@ class StrategyModule(StrategyBase):
final_block = new_block.filter_tagged_tasks(play_context, task_vars)
display.debug("done filtering new block on tags")
- noop_block = Block(parent_block=task._parent)
- noop_block.block = [noop_task for t in new_block.block]
- noop_block.always = [noop_task for t in new_block.always]
- noop_block.rescue = [noop_task for t in new_block.rescue]
+ noop_block = _create_noop_block(final_block, task._parent)
for host in hosts_left:
if host in included_file._hosts:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment