Commit 4b6525fb by James Cammarata

Fix handler flushing to match how v1 worked

Also adds meta tasks to the list of tasks excluded from tag filtering

Fixes #11574
parent d0dcf737
...@@ -322,7 +322,7 @@ class Block(Base, Become, Conditional, Taggable): ...@@ -322,7 +322,7 @@ class Block(Base, Become, Conditional, Taggable):
def evaluate_and_append_task(target): def evaluate_and_append_task(target):
tmp_list = [] tmp_list = []
for task in target: for task in target:
if task.action == 'include' or task.evaluate_tags(play_context.only_tags, play_context.skip_tags, all_vars=all_vars): if task.action in ('meta', 'include') or task.evaluate_tags(play_context.only_tags, play_context.skip_tags, all_vars=all_vars):
tmp_list.append(task) tmp_list.append(task)
return tmp_list return tmp_list
......
...@@ -26,10 +26,11 @@ from ansible.errors import AnsibleError, AnsibleParserError ...@@ -26,10 +26,11 @@ from ansible.errors import AnsibleError, AnsibleParserError
from ansible.playbook.attribute import Attribute, FieldAttribute from ansible.playbook.attribute import Attribute, FieldAttribute
from ansible.playbook.base import Base from ansible.playbook.base import Base
from ansible.playbook.become import Become from ansible.playbook.become import Become
from ansible.playbook.block import Block
from ansible.playbook.helpers import load_list_of_blocks, load_list_of_roles from ansible.playbook.helpers import load_list_of_blocks, load_list_of_roles
from ansible.playbook.role import Role from ansible.playbook.role import Role
from ansible.playbook.taggable import Taggable from ansible.playbook.taggable import Taggable
from ansible.playbook.block import Block from ansible.playbook.task import Task
from ansible.utils.vars import combine_vars from ansible.utils.vars import combine_vars
...@@ -270,12 +271,25 @@ class Play(Base, Taggable, Become): ...@@ -270,12 +271,25 @@ class Play(Base, Taggable, Become):
tasks specified in the play. tasks specified in the play.
''' '''
# create a block containing a single flush handlers meta
# task, so we can be sure to run handlers at certain points
# of the playbook execution
flush_block = Block.load(
data={'meta': 'flush_handlers'},
play=self,
variable_manager=self._variable_manager,
loader=self._loader
)
block_list = [] block_list = []
block_list.extend(self.pre_tasks) block_list.extend(self.pre_tasks)
block_list.append(flush_block)
block_list.extend(self._compile_roles()) block_list.extend(self._compile_roles())
block_list.extend(self.tasks) block_list.extend(self.tasks)
block_list.append(flush_block)
block_list.extend(self.post_tasks) block_list.extend(self.post_tasks)
block_list.append(flush_block)
return block_list return block_list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment