mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07:00
rearranged --list- options, now they are consolidated when used toghether, less loops, more concise output
list-hosts works list-tasks works, but needs better task naming (missing role info) list-tags only shows play tags
This commit is contained in:
parent
b8336f222d
commit
056602c424
2 changed files with 36 additions and 34 deletions
|
@ -151,19 +151,43 @@ class PlaybookCLI(CLI):
|
|||
for p in results:
|
||||
|
||||
self.display.display('\nplaybook: %s\n' % p['playbook'])
|
||||
i = 1
|
||||
for play in p['plays']:
|
||||
if play.name:
|
||||
playname = play.name
|
||||
else:
|
||||
playname = '#' + str(i)
|
||||
|
||||
msg = "\n PLAY: %s" % (playname)
|
||||
if self.options.listtags:
|
||||
mytags = set(play.tags)
|
||||
msg += '\n total tags: %d' % (len(mytags))
|
||||
msg += '\n tags: [%s]' % (','.join(mytags))
|
||||
|
||||
if self.options.listhosts:
|
||||
self.display.display("\n %s (%s): host count=%d" % (play['name'], play['pattern'], len(play['hosts'])))
|
||||
for host in play['hosts']:
|
||||
self.display.display(" %s" % host)
|
||||
if self.options.listtasks: #TODO: do we want to display block info?
|
||||
self.display.display("\n %s" % (play['name']))
|
||||
for task in play['tasks']:
|
||||
self.display.display(" %s" % task)
|
||||
if self.options.listtags: #TODO: fix once we figure out block handling above
|
||||
self.display.display("\n %s: tags count=%d" % (play['name'], len(play['tags'])))
|
||||
for tag in play['tags']:
|
||||
self.display.display(" %s" % tag)
|
||||
playhosts = set(inventory.get_hosts(play.hosts))
|
||||
msg += "\n pattern: %s\n total hosts: %d\n hosts:" % (play.hosts, len(playhosts))
|
||||
for host in playhosts:
|
||||
msg += "\n %s" % host
|
||||
|
||||
self.display.display(msg)
|
||||
|
||||
if self.options.listtags or self.options.listtasks:
|
||||
j = 1
|
||||
taskmsg = ' tasks:'
|
||||
for task in play.get_tasks():
|
||||
taskmsg += "\n %s" % task
|
||||
|
||||
if self.options.listtags:
|
||||
pass
|
||||
#for task in play.get_tasks():
|
||||
# mytags.union(set(task.tags))
|
||||
#self.display.display(" %s" % ','.join(mytags))
|
||||
|
||||
j = j + 1
|
||||
self.display.display(taskmsg)
|
||||
|
||||
i = i + 1
|
||||
return 0
|
||||
else:
|
||||
return results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue