summaryrefslogtreecommitdiff
path: root/lib/ansible/executor/task_queue_manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/executor/task_queue_manager.py')
-rw-r--r--lib/ansible/executor/task_queue_manager.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py
index d994d7f127..289e0f386e 100644
--- a/lib/ansible/executor/task_queue_manager.py
+++ b/lib/ansible/executor/task_queue_manager.py
@@ -115,19 +115,21 @@ class TaskQueueManager:
self._result_prc = ResultProcess(self._final_q, self._workers)
self._result_prc.start()
- def _initialize_notified_handlers(self, handlers):
+ def _initialize_notified_handlers(self, play):
'''
Clears and initializes the shared notified handlers dict with entries
for each handler in the play, which is an empty array that will contain
inventory hostnames for those hosts triggering the handler.
'''
+ handlers = play.handlers
+ for role in play.roles:
+ handlers.extend(role._handler_blocks)
+
# Zero the dictionary first by removing any entries there.
# Proxied dicts don't support iteritems, so we have to use keys()
- for key in self._notified_handlers.keys():
- del self._notified_handlers[key]
- for key in self._listening_handlers.keys():
- del self._listening_handlers[key]
+ self._notified_handlers.clear()
+ self._listening_handlers.clear()
def _process_block(b):
temp_list = []
@@ -142,9 +144,10 @@ class TaskQueueManager:
for handler_block in handlers:
handler_list.extend(_process_block(handler_block))
- # then initialize it with the handler names from the handler list
+ # then initialize it with the given handler list
for handler in handler_list:
- self._notified_handlers[handler.get_name()] = []
+ if handler not in self._notified_handlers:
+ self._notified_handlers[handler] = []
if handler.listen:
if handler.listen not in self._listening_handlers:
self._listening_handlers[handler.listen] = []
@@ -233,8 +236,7 @@ class TaskQueueManager:
self.send_callback('v2_playbook_on_play_start', new_play)
# initialize the shared dictionary containing the notified handlers
- new_play.handlers = new_play.compile_roles_handlers() + new_play.handlers
- self._initialize_notified_handlers(new_play.handlers)
+ self._initialize_notified_handlers(new_play)
# load the specified strategy (or the default linear one)
strategy = strategy_loader.get(new_play.strategy, self)