From c0dfa8d5121ee3588efc4b036880b25488b6fbb8 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 18 Jun 2015 14:27:20 -0400 Subject: [PATCH] Make sure task names are templated before callbacks are sent --- lib/ansible/playbook/base.py | 2 +- lib/ansible/plugins/strategies/linear.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py index ecd217c1e8..211fff3a3a 100644 --- a/lib/ansible/playbook/base.py +++ b/lib/ansible/playbook/base.py @@ -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): diff --git a/lib/ansible/plugins/strategies/linear.py b/lib/ansible/plugins/strategies/linear.py index b60a922f83..9b78c6e13e 100644 --- a/lib/ansible/plugins/strategies/linear.py +++ b/lib/ansible/plugins/strategies/linear.py @@ -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