summaryrefslogtreecommitdiff
path: root/lib/ansible/playbook/handler.py
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2018-12-11 09:58:19 -0600
committerBrian Coca <bcoca@users.noreply.github.com>2018-12-11 10:58:19 -0500
commit2a469fd9597ac36099e991a1757193e6d3016e63 (patch)
treeef05cea96df424db851c578765010c7936e1c951 /lib/ansible/playbook/handler.py
parent62b2a08cfbc1aeb5a45d45d9e975d74e194cd8d8 (diff)
downloadansible-2a469fd9597ac36099e991a1757193e6d3016e63.tar.gz
Consolidate handler tracking (#49338)
* Consolidate handler tracking - Remove unused code. ci_complete - unit test fixes. ci_complete - Restore previous behavior of matching a single handler - when notifying a host for a handler, return True if it was added, False otherwise, to reduce copied logic - rename funcitons for clarity. ci_complete - Remove handler logic for static includes which was disabled previously
Diffstat (limited to 'lib/ansible/playbook/handler.py')
-rw-r--r--lib/ansible/playbook/handler.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/ansible/playbook/handler.py b/lib/ansible/playbook/handler.py
index b0452c577a..cabbd556ab 100644
--- a/lib/ansible/playbook/handler.py
+++ b/lib/ansible/playbook/handler.py
@@ -25,10 +25,12 @@ from ansible.playbook.task import Task
class Handler(Task):
- _listen = FieldAttribute(isa='list')
+ _listen = FieldAttribute(isa='list', default=list)
def __init__(self, block=None, role=None, task_include=None):
- self._flagged_hosts = []
+ self.notified_hosts = []
+
+ self.cached_name = False
super(Handler, self).__init__(block=block, role=role, task_include=task_include)
@@ -41,13 +43,14 @@ class Handler(Task):
t = Handler(block=block, role=role, task_include=task_include)
return t.load_data(data, variable_manager=variable_manager, loader=loader)
- def flag_for_host(self, host):
- # assert instanceof(host, Host)
- if host not in self._flagged_hosts:
- self._flagged_hosts.append(host)
+ def notify_host(self, host):
+ if not self.is_host_notified(host):
+ self.notified_hosts.append(host)
+ return True
+ return False
- def has_triggered(self, host):
- return host in self._flagged_hosts
+ def is_host_notified(self, host):
+ return host in self.notified_hosts
def serialize(self):
result = super(Handler, self).serialize()