Skip to content

Commit

Permalink
Restore listen handler functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
sivel committed Dec 3, 2018
1 parent e862fd4 commit 551895a
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions lib/ansible/plugins/strategy/__init__.py
Expand Up @@ -394,15 +394,6 @@ def search_handler_blocks_by_name(handler_name, handler_blocks):
continue
return None

def search_handler_blocks_by_listen_name(handler_name, handler_blocks):
# iterate in reversed order since last handler loaded with the same name wins
for handler_block in reversed(handler_blocks):
for handler_task in handler_block.block:
listeners = getattr(handler_task, 'listen', []) or []
if handler_name in listeners:
return handler_task
return None

def parent_handler_match(target_handler, handler_name):
if target_handler:
if isinstance(target_handler, (TaskInclude, IncludeRole)) and not getattr(target_handler, 'statically_loaded', True):
Expand Down Expand Up @@ -566,12 +557,17 @@ def parent_handler_match(target_handler, handler_name):
if found:
break

listening_handler = search_handler_blocks_by_listen_name(handler_name, iterator._play.handlers)
if listening_handler is not None:
found = True
if not listening_handler.is_notified(original_host):
listening_handler.do_notify(original_host)
self._tqm.send_callback('v2_playbook_on_notify', listening_handler, original_host)
for listening_handler_block in iterator._play.handlers:
for listening_handler in listening_handler_block.block:
listeners = getattr(listening_handler, 'listen', []) or []
if handler_name not in listeners:
continue
else:
found = True

if not listening_handler.is_notified(original_host):
listening_handler.do_notify(original_host)
self._tqm.send_callback('v2_playbook_on_notify', listening_handler, original_host)

# and if none were found, then we raise an error
if not found:
Expand Down

0 comments on commit 551895a

Please sign in to comment.