Skip to content

Commit

Permalink
Merge pull request ansible#12663 from Juraci/task-path
Browse files Browse the repository at this point in the history
Displays the absolute path of a given task when verbosity is above level 3
  • Loading branch information
bcoca committed Oct 7, 2015
2 parents dbae110 + e52950a commit c459dd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ansible/playbook/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ def __init__(self, block=None, role=None, task_include=None):

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 '''

Expand Down
4 changes: 4 additions & 0 deletions lib/ansible/plugins/callback/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def v2_playbook_on_no_hosts_remaining(self):

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())
Expand Down

0 comments on commit c459dd4

Please sign in to comment.