Make sure task names are templated before callbacks are sent
This commit is contained in:
parent
98fee172ee
commit
c0dfa8d512
2 changed files with 6 additions and 2 deletions
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue