mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
handler: notify a handler by name _and_ listen
Before we only allowed either notify by name or listen and name had precedence.
This commit is contained in:
parent
ce4330d986
commit
e69d26270f
1 changed files with 16 additions and 16 deletions
|
@ -393,15 +393,6 @@ class StrategyBase:
|
||||||
# dependency chain of the current task (if it's from a role), otherwise
|
# 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
|
# we just look through the list of handlers in the current play/all
|
||||||
# roles and use the first one that matches the notify name
|
# 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)
|
target_handler = search_handler_blocks(handler_name, iterator._play.handlers)
|
||||||
if target_handler is not None:
|
if target_handler is not None:
|
||||||
found = True
|
found = True
|
||||||
|
@ -418,6 +409,15 @@ class StrategyBase:
|
||||||
display.vv("NOTIFIED HANDLER %s" % (target_handler.get_name(),))
|
display.vv("NOTIFIED HANDLER %s" % (target_handler.get_name(),))
|
||||||
found = True
|
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
|
# and if none were found, then we raise an error
|
||||||
if not found:
|
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
|
msg = "The requested handler '%s' was not found in either the main handlers list nor in the listening handlers list" % handler_name
|
||||||
|
|
Loading…
Reference in a new issue