Browse code

Properly template task names in free strategy

* Fixes #16295

Remi Ferrand authored on 2016/06/15 16:49:04
Showing 1 changed files
... ...
@@ -26,6 +26,7 @@ from ansible.playbook.included_file import IncludedFile
26 26
 from ansible.plugins import action_loader
27 27
 from ansible.plugins.strategy import StrategyBase
28 28
 from ansible.template import Templar
29
+from ansible.compat.six import text_type
29 30
 
30 31
 try:
31 32
     from __main__ import display
... ...
@@ -107,6 +108,15 @@ class StrategyModule(StrategyBase):
107 107
                         templar = Templar(loader=self._loader, variables=task_vars)
108 108
                         display.debug("done getting variables")
109 109
 
110
+                        try:
111
+                            task.name = text_type(templar.template(task.name, fail_on_undefined=False))
112
+                            display.debug("done templating")
113
+                        except:
114
+                            # just ignore any errors during task name templating,
115
+                            # we don't care if it just shows the raw name
116
+                            display.debug("templating failed for some reason")
117
+                            pass
118
+
110 119
                         run_once = templar.template(task.run_once) or action and getattr(action, 'BYPASS_HOST_LOOP', False)
111 120
                         if run_once:
112 121
                             if action and getattr(action, 'BYPASS_HOST_LOOP', False):