Fix the way handlers are compiled and found/notified

* Instead of rebuilding the handler list all over the place, we now
  compile the handlers at the point the play is post-validated so that
  the view of the play in the PlayIterator contains the definitive list
* Assign the dep_chain to the handlers as they're compiling, just as we
  do for regular tasks
* Clean up the logic used to find a given handler, which is greatly
  simplified by the above changes

Fixes #15418
This commit is contained in:
James Cammarata 2016-07-06 14:40:11 -05:00
commit 930d090507
4 changed files with 32 additions and 29 deletions

View file

@ -122,10 +122,6 @@ class TaskQueueManager:
inventory hostnames for those hosts triggering the handler.
'''
handlers = play.handlers
for role in play.roles:
handlers.extend(role.get_handler_blocks())
# Zero the dictionary first by removing any entries there.
# Proxied dicts don't support iteritems, so we have to use keys()
self._notified_handlers.clear()
@ -141,7 +137,7 @@ class TaskQueueManager:
return temp_list
handler_list = []
for handler_block in handlers:
for handler_block in play.handlers:
handler_list.extend(_process_block(handler_block))
# then initialize it with the given handler list
@ -220,6 +216,7 @@ class TaskQueueManager:
new_play = play.copy()
new_play.post_validate(templar)
new_play.handlers = new_play.compile_roles_handlers() + new_play.handlers
self.hostvars = HostVars(
inventory=self._inventory,