From 21fe750cef331e4b9dc1ec17324ab74e91f08551 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 24 Apr 2013 22:28:06 -0400 Subject: [PATCH] Flush handlers before pre and post task sections change, but not between task and roles, as this seems to be confusing to people (and not usually neccessary) --- lib/ansible/playbook/__init__.py | 6 +++--- lib/ansible/playbook/play.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index ee8db143a3..fdedec78cd 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -224,9 +224,9 @@ class PlayBook(object): # if we have matched_tags, the play must be run. # if the play contains no tasks, assume we just want to gather facts - # in this case there are actually 4 meta tasks (handler flushes) not 0 - # tasks, so that's why there's a check against 4. - if (len(matched_tags) > 0 or len(play.tasks()) == 4): + # in this case there are actually 3 meta tasks (handler flushes) not 0 + # tasks, so that's why there's a check against 3 + if (len(matched_tags) > 0 or len(play.tasks()) == 3): plays.append(play) # if the playbook is invoked with --tags that don't exist at all in the playbooks diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index e7aceb5802..984a32d5cc 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -140,6 +140,8 @@ class Play(object): pre_tasks = [] for x in pre_tasks: new_tasks.append(x) + + # flush handlers after pre_tasks new_tasks.append(dict(meta='flush_handlers')) # variables if the role was parameterized (i.e. given as a hash) @@ -201,10 +203,11 @@ class Play(object): if type(post_tasks) != list: post_tasks = [] - new_tasks.append(dict(meta='flush_handlers')) new_tasks.extend(tasks) + # flush handlers after tasks + role tasks new_tasks.append(dict(meta='flush_handlers')) new_tasks.extend(post_tasks) + # flush handlers after post tasks new_tasks.append(dict(meta='flush_handlers')) new_handlers.extend(handlers) new_vars_files.extend(vars_files)