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

Make sure task names are templated before callbacks are sent

This commit is contained in:
James Cammarata 2015-06-18 14:27:20 -04:00
parent 98fee172ee
commit c0dfa8d512
2 changed files with 6 additions and 2 deletions

View file

@ -281,7 +281,7 @@ class Base:
except (TypeError, ValueError) as e:
raise AnsibleParserError("the field '%s' has an invalid value (%s), and could not be converted to an %s. Error was: %s" % (name, value, attribute.isa, e), obj=self.get_ds())
except UndefinedError as e:
if templar._fail_on_undefined_errors:
if templar._fail_on_undefined_errors and name != 'name':
raise AnsibleParserError("the field '%s' has an invalid value, which appears to include a variable that is undefined. The error was: %s" % (name,e), obj=self.get_ds())
def serialize(self):

View file

@ -26,6 +26,7 @@ from ansible.playbook.included_file import IncludedFile
from ansible.playbook.task import Task
from ansible.plugins import action_loader
from ansible.plugins.strategies import StrategyBase
from ansible.template import Templar
from ansible.utils.debug import debug
class StrategyModule(StrategyBase):
@ -166,6 +167,7 @@ class StrategyModule(StrategyBase):
debug("getting variables")
task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=host, task=task)
templar = Templar(loader=self._loader, variables=task_vars)
debug("done getting variables")
# check to see if this task should be skipped, due to it being a member of a
@ -190,7 +192,9 @@ class StrategyModule(StrategyBase):
raise AnsibleError("invalid meta action requested: %s" % meta_action, obj=task._ds)
else:
if not callback_sent:
self._tqm.send_callback('v2_playbook_on_task_start', task, is_conditional=False)
temp_task = task.copy()
temp_task.name = templar.template(temp_task.get_name(), fail_on_undefined=False)
self._tqm.send_callback('v2_playbook_on_task_start', temp_task, is_conditional=False)
callback_sent = True
self._blocked_hosts[host.get_name()] = True