mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Further tweaks to the output format of list tasks/tags
This commit is contained in:
parent
5929ffc7c3
commit
d4ffc96c80
1 changed files with 17 additions and 4 deletions
|
@ -156,7 +156,7 @@ class PlaybookCLI(CLI):
|
||||||
for idx, play in enumerate(p['plays']):
|
for idx, play in enumerate(p['plays']):
|
||||||
msg = "\n play #%d (%s): %s" % (idx + 1, ','.join(play.hosts), play.name)
|
msg = "\n play #%d (%s): %s" % (idx + 1, ','.join(play.hosts), play.name)
|
||||||
mytags = set(play.tags)
|
mytags = set(play.tags)
|
||||||
msg += ' TAGS: [%s]' % (','.join(mytags))
|
msg += '\tTAGS: [%s]' % (','.join(mytags))
|
||||||
|
|
||||||
if self.options.listhosts:
|
if self.options.listhosts:
|
||||||
playhosts = set(inventory.get_hosts(play.hosts))
|
playhosts = set(inventory.get_hosts(play.hosts))
|
||||||
|
@ -166,8 +166,11 @@ class PlaybookCLI(CLI):
|
||||||
|
|
||||||
display.display(msg)
|
display.display(msg)
|
||||||
|
|
||||||
|
all_tags = set()
|
||||||
if self.options.listtags or self.options.listtasks:
|
if self.options.listtags or self.options.listtasks:
|
||||||
taskmsg = ' tasks:'
|
taskmsg = ''
|
||||||
|
if self.options.listtasks:
|
||||||
|
taskmsg = ' tasks:\n'
|
||||||
|
|
||||||
all_vars = variable_manager.get_vars(loader=loader, play=play)
|
all_vars = variable_manager.get_vars(loader=loader, play=play)
|
||||||
play_context = PlayContext(play=play, options=self.options)
|
play_context = PlayContext(play=play, options=self.options)
|
||||||
|
@ -179,8 +182,18 @@ class PlaybookCLI(CLI):
|
||||||
for task in block.block:
|
for task in block.block:
|
||||||
if task.action == 'meta':
|
if task.action == 'meta':
|
||||||
continue
|
continue
|
||||||
taskmsg += "\n %s" % task.get_name()
|
|
||||||
taskmsg += " TAGS: [%s]" % ','.join(mytags.union(set(task.tags)))
|
all_tags.update(task.tags)
|
||||||
|
if self.options.listtasks:
|
||||||
|
cur_tags = list(mytags.union(set(task.tags)))
|
||||||
|
cur_tags.sort()
|
||||||
|
taskmsg += " %s" % task.action
|
||||||
|
taskmsg += "\tTAGS: [%s]\n" % ', '.join(cur_tags)
|
||||||
|
|
||||||
|
if self.options.listtags:
|
||||||
|
cur_tags = list(mytags.union(all_tags))
|
||||||
|
cur_tags.sort()
|
||||||
|
taskmsg += " TASK TAGS: [%s]\n" % ', '.join(cur_tags)
|
||||||
|
|
||||||
display.display(taskmsg)
|
display.display(taskmsg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue