From ec4d1b11df5d2dc4f9bf13171eb83ec1c966b3e5 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 30 Jun 2015 14:44:41 -0400 Subject: [PATCH] Fix some more handler issues * Only notify handlers when the task is changed * Don't run handlers on hosts which have failed --- lib/ansible/executor/process/result.py | 2 +- lib/ansible/plugins/strategies/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/executor/process/result.py b/lib/ansible/executor/process/result.py index 1b8f4f5d31..7fbee9a1b6 100644 --- a/lib/ansible/executor/process/result.py +++ b/lib/ansible/executor/process/result.py @@ -123,7 +123,7 @@ class ResultProcess(multiprocessing.Process): self._send_result(('host_task_skipped', result)) else: # if this task is notifying a handler, do it now - if result._task.notify: + if result._task.notify and result._result.get('changed', False): # The shared dictionary for notified handlers is a proxy, which # does not detect when sub-objects within the proxy are modified. # So, per the docs, we reassign the list so the proxy picks up and diff --git a/lib/ansible/plugins/strategies/__init__.py b/lib/ansible/plugins/strategies/__init__.py index 0b78a245dd..a298b19988 100644 --- a/lib/ansible/plugins/strategies/__init__.py +++ b/lib/ansible/plugins/strategies/__init__.py @@ -380,7 +380,7 @@ class StrategyBase: break self._tqm.send_callback('v2_playbook_on_handler_task_start', handler) for host in self._notified_handlers[handler_name]: - if not handler.has_triggered(host): + if not handler.has_triggered(host) and host.name not in self._tqm._failed_hosts: task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=host, task=handler) task_vars = self.add_tqm_variables(task_vars, play=iterator._play) self._queue_task(host, handler, task_vars, connection_info)