added list-tags option and also show tags in list-tasks option
This commit is contained in:
parent
919db1025c
commit
8267bb2ae1
1 changed files with 20 additions and 9 deletions
|
@ -91,6 +91,8 @@ def main(args):
|
||||||
help="perform a syntax check on the playbook, but do not execute it")
|
help="perform a syntax check on the playbook, but do not execute it")
|
||||||
parser.add_option('--list-tasks', dest='listtasks', action='store_true',
|
parser.add_option('--list-tasks', dest='listtasks', action='store_true',
|
||||||
help="list all tasks that would be executed")
|
help="list all tasks that would be executed")
|
||||||
|
parser.add_option('--list-tags', dest='listtags', action='store_true',
|
||||||
|
help="list all available tags")
|
||||||
parser.add_option('--step', dest='step', action='store_true',
|
parser.add_option('--step', dest='step', action='store_true',
|
||||||
help="one-step-at-a-time: confirm each task before running")
|
help="one-step-at-a-time: confirm each task before running")
|
||||||
parser.add_option('--start-at-task', dest='start_at',
|
parser.add_option('--start-at-task', dest='start_at',
|
||||||
|
@ -123,7 +125,7 @@ def main(args):
|
||||||
|
|
||||||
options.ask_vault_pass = options.ask_vault_pass or C.DEFAULT_ASK_VAULT_PASS
|
options.ask_vault_pass = options.ask_vault_pass or C.DEFAULT_ASK_VAULT_PASS
|
||||||
|
|
||||||
if options.listhosts or options.syntax or options.listtasks:
|
if options.listhosts or options.syntax or options.listtasks or options.listtags:
|
||||||
(_, _, _, vault_pass) = utils.ask_passwords(ask_vault_pass=options.ask_vault_pass)
|
(_, _, _, vault_pass) = utils.ask_passwords(ask_vault_pass=options.ask_vault_pass)
|
||||||
else:
|
else:
|
||||||
options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS
|
options.ask_pass = options.ask_pass or C.DEFAULT_ASK_PASS
|
||||||
|
@ -215,7 +217,7 @@ def main(args):
|
||||||
display(callbacks.banner("FLUSHING FACT CACHE"))
|
display(callbacks.banner("FLUSHING FACT CACHE"))
|
||||||
pb.SETUP_CACHE.flush()
|
pb.SETUP_CACHE.flush()
|
||||||
|
|
||||||
if options.listhosts or options.listtasks or options.syntax:
|
if options.listhosts or options.listtasks or options.syntax or options.listtags:
|
||||||
print ''
|
print ''
|
||||||
print 'playbook: %s' % playbook
|
print 'playbook: %s' % playbook
|
||||||
print ''
|
print ''
|
||||||
|
@ -232,14 +234,23 @@ def main(args):
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
print ' %s' % host
|
print ' %s' % host
|
||||||
|
|
||||||
|
if options.listtags or options.listtasks:
|
||||||
|
print ' play #%d (%s):\tTAGS: [%s]' % (playnum, label,','.join(sorted(set(play.tags))))
|
||||||
|
|
||||||
|
if options.listtags:
|
||||||
|
tags = []
|
||||||
|
for task in pb.tasks_to_run_in_play(play):
|
||||||
|
tags.extend(task.tags)
|
||||||
|
print ' TASK TAGS: [%s]' % (', '.join(sorted(set(tags).difference(['untagged']))))
|
||||||
|
|
||||||
if options.listtasks:
|
if options.listtasks:
|
||||||
print ' play #%d (%s):' % (playnum, label)
|
|
||||||
|
|
||||||
for task in pb.tasks_to_run_in_play(play):
|
for task in pb.tasks_to_run_in_play(play):
|
||||||
if getattr(task, 'name', None) is not None:
|
if getattr(task, 'name', None) is not None:
|
||||||
# meta tasks have no names
|
# meta tasks have no names
|
||||||
print ' %s' % task.name
|
print ' %s\tTAGS: [%s]' % (task.name, ', '.join(sorted(set(task.tags).difference(['untagged']))))
|
||||||
if options.listhosts or options.listtasks:
|
|
||||||
|
if options.listhosts or options.listtasks or options.listtags:
|
||||||
print ''
|
print ''
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue