1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Enhance logging, way to gate verbosity levels pending.

This commit is contained in:
Michael DeHaan 2012-03-20 21:44:01 -04:00
parent 05e27a419c
commit b5c62ec068
5 changed files with 28 additions and 11 deletions

View file

@ -43,6 +43,12 @@ class PlaybookCallbacks(object):
def on_task_start(self, name, is_conditional):
print utils.task_start_msg(name, is_conditional)
def on_setup_primary(self):
print "SETUP PHASE ****************************\n"
def on_setup_secondary(self):
print "\nVARIABLE IMPORT PHASE ******************\n"
def on_unreachable(self, host, msg):
print "unreachable: [%s] => %s" % (host, msg)
@ -52,14 +58,11 @@ class PlaybookCallbacks(object):
def on_ok(self, host, host_result):
print "ok: [%s]\n" % (host)
def on_setup_primary(self):
print "preparing nodes..."
def on_setup_secondary(self):
print "preparing conditional imports..."
def on_import_for_host(self, host, imported_file):
pass
print "%s: importing %s" % (host, imported_file)
def on_not_import_for_host(self, host, missing_file):
print "%s: not importing file: %s" % (host, missing_file)
def on_play_start(self, pattern):
print "PLAY [%s] ****************************\n" % pattern

View file

@ -32,7 +32,6 @@
- "vars/external_vars.yml"
- [ "vars/$facter_operatingsystem.yml", "vars/defaults.yml" ]
# and this is just a regular task line from a playbook, as we're used to.

View file

@ -465,8 +465,12 @@ class PlayBook(object):
SETUP_CACHE[host].update(data)
self.callbacks.on_import_for_host(host, filename2)
break
else:
self.callbacks.on_not_import_for_host(host, filename2)
if not found:
raise errors.AnsibleError("no files matched for vars_files import sequence: %s" % sequence)
raise errors.AnsibleError(
"%s: FATAL, no files matched for vars_files import sequence: %s" % (host, sequence)
)
else:
filename2 = utils.path_dwim(self.basedir, utils.template(filename, cache_vars))
@ -508,6 +512,8 @@ class PlayBook(object):
if 'failed' in host_result:
self.callbacks.on_failed(host, host_result)
self.failures[host] = 1
else:
self.callbacks.on_ok(host, host_result)
# now for each result, load into the setup cache so we can
# let runner template out future commands

View file

@ -54,9 +54,9 @@ def smjson(result):
def task_start_msg(name, conditional):
if conditional:
return "NOTIFIED: [%s] **********\n" % name
return "\nNOTIFIED: [%s] **********\n" % name
else:
return "TASK: [%s] *********\n" % name
return "\nTASK: [%s] *********\n" % name
def regular_generic_msg(hostname, result, oneline, caption):
''' output on the result of a module run that is not command '''

View file

@ -35,6 +35,9 @@ class TestCallbacks(object):
def on_import_for_host(self, host, filename):
self.events.append([ 'import', [ host, filename ]])
def on_not_import_for_host(self, host, missing_filename):
pass
def on_task_start(self, name, is_conditional):
self.events.append([ 'task start', [ name, is_conditional ]])
@ -63,6 +66,12 @@ class TestCallbacks(object):
def on_dark_host(self, host, msg):
self.events.append([ 'failed/dark', [ host, msg ]])
def on_setup_primary(self):
pass
def on_setup_secondary(self):
pass
class TestRunner(unittest.TestCase):