handler: notify a handler by name _and_ listen

Before we only allowed either notify by name or listen and name had precedence.
pull/18190/head
Rene Moser 8 years ago committed by Brian Coca
parent ce4330d986
commit e69d26270f

@ -393,15 +393,6 @@ class StrategyBase:
# dependency chain of the current task (if it's from a role), otherwise
# we just look through the list of handlers in the current play/all
# roles and use the first one that matches the notify name
if handler_name in self._listening_handlers:
for listening_handler_name in self._listening_handlers[handler_name]:
listening_handler = search_handler_blocks(listening_handler_name, iterator._play.handlers)
if listening_handler is not None:
found = True
if original_host not in self._notified_handlers[listening_handler]:
self._notified_handlers[listening_handler].append(original_host)
display.vv("NOTIFIED HANDLER %s" % (listening_handler_name,))
else:
target_handler = search_handler_blocks(handler_name, iterator._play.handlers)
if target_handler is not None:
found = True
@ -418,6 +409,15 @@ class StrategyBase:
display.vv("NOTIFIED HANDLER %s" % (target_handler.get_name(),))
found = True
if handler_name in self._listening_handlers:
for listening_handler_name in self._listening_handlers[handler_name]:
listening_handler = search_handler_blocks(listening_handler_name, iterator._play.handlers)
if listening_handler is not None:
found = True
if original_host not in self._notified_handlers[listening_handler]:
self._notified_handlers[listening_handler].append(original_host)
display.vv("NOTIFIED HANDLER %s" % (listening_handler_name,))
# and if none were found, then we raise an error
if not found:
msg = "The requested handler '%s' was not found in either the main handlers list nor in the listening handlers list" % handler_name

Loading…
Cancel
Save