1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Don't bomb out on handlers with undefined variables in their names

This commit is contained in:
James Cammarata 2015-09-22 12:41:06 -04:00
parent 4b0d52d2cb
commit 3ffc2783c4

View file

@ -24,8 +24,10 @@ from six import iteritems, text_type
import time import time
from jinja2.exceptions import UndefinedError
from ansible import constants as C from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleParserError from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable
from ansible.executor.task_result import TaskResult from ansible.executor.task_result import TaskResult
from ansible.inventory.host import Host from ansible.inventory.host import Host
from ansible.inventory.group import Group from ansible.inventory.group import Group
@ -466,7 +468,14 @@ class StrategyBase:
for handler in handler_block.block: for handler in handler_block.block:
handler_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, task=handler) handler_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, task=handler)
templar = Templar(loader=self._loader, variables=handler_vars) templar = Templar(loader=self._loader, variables=handler_vars)
try:
handler_name = templar.template(handler.get_name()) 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]) should_run = handler_name in self._notified_handlers and len(self._notified_handlers[handler_name])
if should_run: if should_run:
result = self._do_handler_run(handler, handler_name, iterator=iterator, play_context=play_context) result = self._do_handler_run(handler, handler_name, iterator=iterator, play_context=play_context)