mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-05 08:00:22 -07:00
implemented verbosity, added 5th level and now can see how many plays per playbooko if -vvvvv
This commit is contained in:
parent
5531b84360
commit
b1e6aaa790
4 changed files with 13 additions and 10 deletions
|
@ -127,6 +127,7 @@ class PlaybookExecutor:
|
||||||
|
|
||||||
if entry:
|
if entry:
|
||||||
entrylist.append(entry) # per playbook
|
entrylist.append(entry) # per playbook
|
||||||
|
self._display.vvvvv('%d plays in %s' % (i, playbook_path))
|
||||||
|
|
||||||
if entrylist:
|
if entrylist:
|
||||||
return entrylist
|
return entrylist
|
||||||
|
|
|
@ -26,11 +26,9 @@ from ansible.utils.color import stringc
|
||||||
|
|
||||||
class Display:
|
class Display:
|
||||||
|
|
||||||
def __init__(self, conn_info=None):
|
def __init__(self, verbosity=0):
|
||||||
if conn_info:
|
|
||||||
self._verbosity = conn_info.verbosity
|
self.verbosity = verbosity
|
||||||
else:
|
|
||||||
self._verbosity = 0
|
|
||||||
|
|
||||||
# list of all deprecation messages to prevent duplicate display
|
# list of all deprecation messages to prevent duplicate display
|
||||||
self._deprecations = {}
|
self._deprecations = {}
|
||||||
|
@ -70,10 +68,13 @@ class Display:
|
||||||
def vvvv(self, msg, host=None):
|
def vvvv(self, msg, host=None):
|
||||||
return self.verbose(msg, host=host, caplevel=3)
|
return self.verbose(msg, host=host, caplevel=3)
|
||||||
|
|
||||||
|
def vvvvv(self, msg, host=None):
|
||||||
|
return self.verbose(msg, host=host, caplevel=4)
|
||||||
|
|
||||||
def verbose(self, msg, host=None, caplevel=2):
|
def verbose(self, msg, host=None, caplevel=2):
|
||||||
# FIXME: this needs to be implemented
|
# FIXME: this needs to be implemented
|
||||||
#msg = utils.sanitize_output(msg)
|
#msg = utils.sanitize_output(msg)
|
||||||
if self._verbosity > caplevel:
|
if self.verbosity > caplevel:
|
||||||
if host is None:
|
if host is None:
|
||||||
self.display(msg, color='blue')
|
self.display(msg, color='blue')
|
||||||
else:
|
else:
|
||||||
|
@ -124,4 +125,3 @@ class Display:
|
||||||
star_len = 3
|
star_len = 3
|
||||||
stars = "*" * star_len
|
stars = "*" * star_len
|
||||||
self.display("\n%s %s" % (msg, stars), color=color)
|
self.display("\n%s %s" % (msg, stars), color=color)
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ class Cli(object):
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
display.verbosity = options.verbosity
|
||||||
validate_conflicts(parser,options)
|
validate_conflicts(parser,options)
|
||||||
|
|
||||||
return (options, args)
|
return (options, args)
|
||||||
|
@ -109,7 +110,7 @@ class Cli(object):
|
||||||
|
|
||||||
if options.listhosts:
|
if options.listhosts:
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
self.display(' %s' % host.name)
|
self.display.display(' %s' % host.name)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if ((options.module_name == 'command' or options.module_name == 'shell') and not options.module_args):
|
if ((options.module_name == 'command' or options.module_name == 'shell') and not options.module_args):
|
||||||
|
@ -163,7 +164,7 @@ class Cli(object):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
#display.display(" ".join(sys.argv), log_only=True)
|
#display.display(" ".join(sys.argv))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cli = Cli(display=display)
|
cli = Cli(display=display)
|
||||||
|
|
|
@ -53,6 +53,7 @@ def main(display, args):
|
||||||
parser.print_help(file=sys.stderr)
|
parser.print_help(file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
display.verbosity = options.verbosity
|
||||||
validate_conflicts(parser,options)
|
validate_conflicts(parser,options)
|
||||||
|
|
||||||
# Note: slightly wrong, this is written so that implicit localhost
|
# Note: slightly wrong, this is written so that implicit localhost
|
||||||
|
@ -154,7 +155,7 @@ def main(display, args):
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
display.display(" ".join(sys.argv), log_only=True)
|
#display.display(" ".join(sys.argv), log_only=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sys.exit(main(display, sys.argv[1:]))
|
sys.exit(main(display, sys.argv[1:]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue