Fix handler flushing to match how v1 worked

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

Fixes #11574
This commit is contained in:
James Cammarata 2015-07-22 11:20:50 -04:00
parent d0dcf73716
commit 4b6525fb58
2 changed files with 16 additions and 2 deletions

View file

@ -322,7 +322,7 @@ class Block(Base, Become, Conditional, Taggable):
def evaluate_and_append_task(target):
tmp_list = []
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)
return tmp_list

View file

@ -26,10 +26,11 @@ from ansible.errors import AnsibleError, AnsibleParserError
from ansible.playbook.attribute import Attribute, FieldAttribute
from ansible.playbook.base import Base
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.role import Role
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
@ -270,12 +271,25 @@ class Play(Base, Taggable, Become):
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.extend(self.pre_tasks)
block_list.append(flush_block)
block_list.extend(self._compile_roles())
block_list.extend(self.tasks)
block_list.append(flush_block)
block_list.extend(self.post_tasks)
block_list.append(flush_block)
return block_list