Don't assume handlers exist in the same role (if any)

Fixes #12536
pull/12564/head
James Cammarata 9 years ago
parent 8095b027bf
commit a3e913da62

@ -142,9 +142,6 @@ class ResultProcess(multiprocessing.Process):
# So, per the docs, we reassign the list so the proxy picks up and
# notifies all other threads
for notify in result_item['_ansible_notify']:
if result._task._role:
role_name = result._task._role.get_name()
notify = "%s : %s" % (role_name, notify)
self._send_result(('notify_handler', result, notify))
# now remove the notify field from the results, as its no longer needed
result_item.pop('_ansible_notify')

@ -48,7 +48,7 @@ class IncludedFile:
for res in results:
if res._host.name in tqm._failed_hosts:
raise AnsibleError("host is failed, not including files")
continue
if res._task.action == 'include':
if res._task.loop:

@ -237,6 +237,7 @@ class StrategyBase:
if task_result._host not in self._notified_handlers[handler_name]:
self._notified_handlers[handler_name].append(task_result._host)
self._display.vv("NOTIFIED HANDLER %s" % (handler_name,))
elif result[0] == 'register_host_var':
# essentially the same as 'set_host_var' below, however we
@ -447,6 +448,12 @@ class StrategyBase:
handler_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, task=handler)
templar = Templar(loader=self._loader, variables=handler_vars)
try:
# first we check with the full result of get_name(), which may
# include the role name (if the handler is from a role). If that
# is not found, we resort to the simple name field, which doesn't
# have anything extra added to it.
handler_name = templar.template(handler.name)
if handler_name not in self._notified_handlers:
handler_name = templar.template(handler.get_name())
except (UndefinedError, AnsibleUndefinedVariable):
# We skip this handler due to the fact that it may be using
@ -454,8 +461,8 @@ class StrategyBase:
# set_fact or some other method, and we don't want to error
# out unnecessarily
continue
should_run = handler_name in self._notified_handlers and len(self._notified_handlers[handler_name])
if should_run:
if handler_name in self._notified_handlers and len(self._notified_handlers[handler_name]):
result = self._do_handler_run(handler, handler_name, iterator=iterator, play_context=play_context)
if not result:
break

Loading…
Cancel
Save