From a3e913da62a0182368569e91b30c568b24a63b0f Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 29 Sep 2015 12:29:02 -0400 Subject: [PATCH] Don't assume handlers exist in the same role (if any) Fixes #12536 --- lib/ansible/executor/process/result.py | 3 --- lib/ansible/playbook/included_file.py | 2 +- lib/ansible/plugins/strategy/__init__.py | 13 ++++++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/ansible/executor/process/result.py b/lib/ansible/executor/process/result.py index 26ecc2a6403..37970f392c5 100644 --- a/lib/ansible/executor/process/result.py +++ b/lib/ansible/executor/process/result.py @@ -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') diff --git a/lib/ansible/playbook/included_file.py b/lib/ansible/playbook/included_file.py index 3642bbadb38..7f953339477 100644 --- a/lib/ansible/playbook/included_file.py +++ b/lib/ansible/playbook/included_file.py @@ -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: diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 3499094a83e..39d68f8e501 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -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,15 +448,21 @@ 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: - handler_name = templar.template(handler.get_name()) + # 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 # a variable in the name that was conditionally included via # 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