From 254d6be5201903c6529aa5e0dc83383b74dda3f8 Mon Sep 17 00:00:00 2001 From: Juraci Date: Wed, 7 Oct 2015 10:10:57 -0300 Subject: [PATCH 1/2] Adding get_path method to Task class --- lib/ansible/playbook/task.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index c225c8b972..bc32903f7f 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -101,6 +101,12 @@ class Task(Base, Conditional, Taggable, Become): super(Task, self).__init__() + def get_path(self): + ''' return the absolute path of the task with its line number ''' + + if hasattr(self, '_ds'): + return "%s:%s" % (self._ds._data_source, self._ds._line_number) + def get_name(self): ''' return the name of the task ''' From e52950a939aa03b0dd100283a757723349eced1e Mon Sep 17 00:00:00 2001 From: Juraci Date: Wed, 7 Oct 2015 10:11:50 -0300 Subject: [PATCH 2/2] Displaying task_path on task start when verbosity is more than 3 --- lib/ansible/plugins/callback/default.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/plugins/callback/default.py b/lib/ansible/plugins/callback/default.py index e5f8ed12cc..a10ee349c3 100644 --- a/lib/ansible/plugins/callback/default.py +++ b/lib/ansible/plugins/callback/default.py @@ -110,6 +110,10 @@ class CallbackModule(CallbackBase): def v2_playbook_on_task_start(self, task, is_conditional): self._display.banner("TASK [%s]" % task.get_name().strip()) + if self._display.verbosity > 3: + path = task.get_path() + if path: + self._display.display("task path: %s" % path, color='cyan') def v2_playbook_on_cleanup_task_start(self, task): self._display.banner("CLEANUP TASK [%s]" % task.get_name().strip())