|
|
@ -464,28 +464,34 @@ class StrategyBase:
|
|
|
|
# but this may take some work in the iterator and gets tricky when
|
|
|
|
# but this may take some work in the iterator and gets tricky when
|
|
|
|
# we consider the ability of meta tasks to flush handlers
|
|
|
|
# we consider the ability of meta tasks to flush handlers
|
|
|
|
for handler in handler_block.block:
|
|
|
|
for handler in handler_block.block:
|
|
|
|
handler_name = handler.get_name()
|
|
|
|
should_run = handler.get_name() in self._notified_handlers and len(self._notified_handlers[handler.get_name()])
|
|
|
|
if handler_name in self._notified_handlers and len(self._notified_handlers[handler_name]):
|
|
|
|
if should_run:
|
|
|
|
|
|
|
|
result = self._do_handler_run(handler, iterator=iterator, play_context=play_context)
|
|
|
|
|
|
|
|
if not result:
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _do_handler_run(self, handler, iterator, play_context, notified_hosts=None):
|
|
|
|
|
|
|
|
|
|
|
|
# FIXME: need to use iterator.get_failed_hosts() instead?
|
|
|
|
# FIXME: need to use iterator.get_failed_hosts() instead?
|
|
|
|
#if not len(self.get_hosts_remaining(iterator._play)):
|
|
|
|
#if not len(self.get_hosts_remaining(iterator._play)):
|
|
|
|
# self._tqm.send_callback('v2_playbook_on_no_hosts_remaining')
|
|
|
|
# self._tqm.send_callback('v2_playbook_on_no_hosts_remaining')
|
|
|
|
# result = False
|
|
|
|
# result = False
|
|
|
|
# break
|
|
|
|
# break
|
|
|
|
self._tqm.send_callback('v2_playbook_on_handler_task_start', handler)
|
|
|
|
self._tqm.send_callback('v2_playbook_on_handler_task_start', handler)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if notified_hosts is None:
|
|
|
|
|
|
|
|
notified_hosts = self._notified_handlers[handler.get_name()]
|
|
|
|
|
|
|
|
|
|
|
|
host_results = []
|
|
|
|
host_results = []
|
|
|
|
for host in self._notified_handlers[handler_name]:
|
|
|
|
for host in notified_hosts:
|
|
|
|
if not handler.has_triggered(host) and (host.name not in self._tqm._failed_hosts or play_context.force_handlers):
|
|
|
|
if not handler.has_triggered(host) and (host.name not in self._tqm._failed_hosts or play_context.force_handlers):
|
|
|
|
task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=host, task=handler)
|
|
|
|
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)
|
|
|
|
task_vars = self.add_tqm_variables(task_vars, play=iterator._play)
|
|
|
|
self._queue_task(host, handler, task_vars, play_context)
|
|
|
|
self._queue_task(host, handler, task_vars, play_context)
|
|
|
|
#handler.flag_for_host(host)
|
|
|
|
|
|
|
|
results = self._process_pending_results(iterator)
|
|
|
|
|
|
|
|
host_results.extend(results)
|
|
|
|
|
|
|
|
results = self._wait_on_pending_results(iterator)
|
|
|
|
|
|
|
|
host_results.extend(results)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# wipe the notification list
|
|
|
|
# collect the results from the handler run
|
|
|
|
self._notified_handlers[handler_name] = []
|
|
|
|
host_results = self._wait_on_pending_results(iterator)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
included_files = IncludedFile.process_include_results(
|
|
|
|
included_files = IncludedFile.process_include_results(
|
|
|
@ -498,6 +504,7 @@ class StrategyBase:
|
|
|
|
except AnsibleError as e:
|
|
|
|
except AnsibleError as e:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = True
|
|
|
|
if len(included_files) > 0:
|
|
|
|
if len(included_files) > 0:
|
|
|
|
for included_file in included_files:
|
|
|
|
for included_file in included_files:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -505,22 +512,25 @@ class StrategyBase:
|
|
|
|
# for every task in each block brought in by the include, add the list
|
|
|
|
# for every task in each block brought in by the include, add the list
|
|
|
|
# of hosts which included the file to the notified_handlers dict
|
|
|
|
# of hosts which included the file to the notified_handlers dict
|
|
|
|
for block in new_blocks:
|
|
|
|
for block in new_blocks:
|
|
|
|
|
|
|
|
iterator._play.handlers.append(block)
|
|
|
|
for task in block.block:
|
|
|
|
for task in block.block:
|
|
|
|
if task.name in self._notified_handlers:
|
|
|
|
result = self._do_handler_run(
|
|
|
|
for host in included_file._hosts:
|
|
|
|
handler=task,
|
|
|
|
if host.name not in self._notified_handlers[task.name]:
|
|
|
|
iterator=iterator,
|
|
|
|
self._notified_handlers[task.name].append(host)
|
|
|
|
play_context=play_context,
|
|
|
|
else:
|
|
|
|
notified_hosts=included_file._hosts[:],
|
|
|
|
self._notified_handlers[task.name] = included_file._hosts[:]
|
|
|
|
)
|
|
|
|
# and add the new blocks to the list of handler blocks
|
|
|
|
if not result:
|
|
|
|
handler_block.block.extend(block.block)
|
|
|
|
break
|
|
|
|
#iterator._play.handlers.extend(new_blocks)
|
|
|
|
|
|
|
|
except AnsibleError as e:
|
|
|
|
except AnsibleError as e:
|
|
|
|
for host in included_file._hosts:
|
|
|
|
for host in included_file._hosts:
|
|
|
|
iterator.mark_host_failed(host)
|
|
|
|
iterator.mark_host_failed(host)
|
|
|
|
self._tqm._failed_hosts[host.name] = True
|
|
|
|
self._tqm._failed_hosts[host.name] = True
|
|
|
|
self._display.warning(str(e))
|
|
|
|
self._display.warning(str(e))
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# wipe the notification list
|
|
|
|
|
|
|
|
self._notified_handlers[handler.get_name()] = []
|
|
|
|
self._display.debug("done running handlers, result is: %s" % result)
|
|
|
|
self._display.debug("done running handlers, result is: %s" % result)
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|