From 7bc789ba64583fdb68e8ab9c8336dbb9b8374797 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 23 Jul 2015 15:45:36 -0400 Subject: [PATCH] Properly template task names Also fixes in the correct way the bug in which the role name was incorrectly showing up twice in the task name. Fixes #10347 --- lib/ansible/playbook/task.py | 2 +- lib/ansible/plugins/strategies/linear.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 32f47b602a..ca163ca7e5 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -97,7 +97,7 @@ class Task(Base, Conditional, Taggable, Become): def get_name(self): ''' return the name of the task ''' - if self._role and self.name and not self.name.startswith("%s :" % self._role.get_name()): + if self._role and self.name: return "%s : %s" % (self._role.get_name(), self.name) elif self.name: return self.name diff --git a/lib/ansible/plugins/strategies/linear.py b/lib/ansible/plugins/strategies/linear.py index 5ff8abb6fe..a00a936cba 100644 --- a/lib/ansible/plugins/strategies/linear.py +++ b/lib/ansible/plugins/strategies/linear.py @@ -191,7 +191,12 @@ class StrategyModule(StrategyBase): if not callback_sent: temp_task = task.copy() - temp_task.name = templar.template(temp_task.get_name(), fail_on_undefined=False) + try: + temp_task.name = unicode(templar.template(temp_task.name, fail_on_undefined=False)) + except: + # just ignore any errors during task name templating, + # we don't care if it just shows the raw name + pass self._tqm.send_callback('v2_playbook_on_task_start', temp_task, is_conditional=False) callback_sent = True