From 7ff9942ec6db86430210f21ca9ba0ff1844cce15 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 3 Nov 2016 11:57:23 -0500 Subject: [PATCH] Correctly reassign implicit block parents when an include is involved --- lib/ansible/playbook/helpers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py index ba1d0826cc..5b12c0fc7a 100644 --- a/lib/ansible/playbook/helpers.py +++ b/lib/ansible/playbook/helpers.py @@ -40,6 +40,8 @@ def load_list_of_blocks(ds, play, parent_block=None, role=None, task_include=Non # we import here to prevent a circular dependency with imports from ansible.playbook.block import Block + from ansible.playbook.task_include import TaskInclude + from ansible.playbook.role_include import IncludeRole assert isinstance(ds, (list, type(None))) @@ -61,7 +63,10 @@ def load_list_of_blocks(ds, play, parent_block=None, role=None, task_include=Non # squash them down to a single block to save processing time later. if b._implicit and len(block_list) > 0 and block_list[-1]._implicit: for t in b.block: - t._parent = block_list[-1] + if isinstance(t._parent, (TaskInclude, IncludeRole)): + t._parent._parent = block_list[-1] + else: + t._parent = block_list[-1] block_list[-1].block.extend(b.block) else: block_list.append(b)