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:
parent
05e27a419c
commit
b5c62ec068
5 changed files with 28 additions and 11 deletions
|
@ -43,6 +43,12 @@ class PlaybookCallbacks(object):
|
||||||
def on_task_start(self, name, is_conditional):
|
def on_task_start(self, name, is_conditional):
|
||||||
print utils.task_start_msg(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):
|
def on_unreachable(self, host, msg):
|
||||||
print "unreachable: [%s] => %s" % (host, msg)
|
print "unreachable: [%s] => %s" % (host, msg)
|
||||||
|
|
||||||
|
@ -52,14 +58,11 @@ class PlaybookCallbacks(object):
|
||||||
def on_ok(self, host, host_result):
|
def on_ok(self, host, host_result):
|
||||||
print "ok: [%s]\n" % (host)
|
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):
|
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):
|
def on_play_start(self, pattern):
|
||||||
print "PLAY [%s] ****************************\n" % pattern
|
print "PLAY [%s] ****************************\n" % pattern
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
|
|
||||||
- "vars/external_vars.yml"
|
- "vars/external_vars.yml"
|
||||||
|
|
||||||
|
|
||||||
- [ "vars/$facter_operatingsystem.yml", "vars/defaults.yml" ]
|
- [ "vars/$facter_operatingsystem.yml", "vars/defaults.yml" ]
|
||||||
|
|
||||||
# and this is just a regular task line from a playbook, as we're used to.
|
# and this is just a regular task line from a playbook, as we're used to.
|
||||||
|
|
|
@ -465,8 +465,12 @@ class PlayBook(object):
|
||||||
SETUP_CACHE[host].update(data)
|
SETUP_CACHE[host].update(data)
|
||||||
self.callbacks.on_import_for_host(host, filename2)
|
self.callbacks.on_import_for_host(host, filename2)
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
self.callbacks.on_not_import_for_host(host, filename2)
|
||||||
if not found:
|
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:
|
else:
|
||||||
filename2 = utils.path_dwim(self.basedir, utils.template(filename, cache_vars))
|
filename2 = utils.path_dwim(self.basedir, utils.template(filename, cache_vars))
|
||||||
|
@ -508,6 +512,8 @@ class PlayBook(object):
|
||||||
if 'failed' in host_result:
|
if 'failed' in host_result:
|
||||||
self.callbacks.on_failed(host, host_result)
|
self.callbacks.on_failed(host, host_result)
|
||||||
self.failures[host] = 1
|
self.failures[host] = 1
|
||||||
|
else:
|
||||||
|
self.callbacks.on_ok(host, host_result)
|
||||||
|
|
||||||
# now for each result, load into the setup cache so we can
|
# now for each result, load into the setup cache so we can
|
||||||
# let runner template out future commands
|
# let runner template out future commands
|
||||||
|
|
|
@ -54,9 +54,9 @@ def smjson(result):
|
||||||
|
|
||||||
def task_start_msg(name, conditional):
|
def task_start_msg(name, conditional):
|
||||||
if conditional:
|
if conditional:
|
||||||
return "NOTIFIED: [%s] **********\n" % name
|
return "\nNOTIFIED: [%s] **********\n" % name
|
||||||
else:
|
else:
|
||||||
return "TASK: [%s] *********\n" % name
|
return "\nTASK: [%s] *********\n" % name
|
||||||
|
|
||||||
def regular_generic_msg(hostname, result, oneline, caption):
|
def regular_generic_msg(hostname, result, oneline, caption):
|
||||||
''' output on the result of a module run that is not command '''
|
''' output on the result of a module run that is not command '''
|
||||||
|
|
|
@ -35,6 +35,9 @@ class TestCallbacks(object):
|
||||||
def on_import_for_host(self, host, filename):
|
def on_import_for_host(self, host, filename):
|
||||||
self.events.append([ 'import', [ 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):
|
def on_task_start(self, name, is_conditional):
|
||||||
self.events.append([ 'task start', [ 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):
|
def on_dark_host(self, host, msg):
|
||||||
self.events.append([ 'failed/dark', [ 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):
|
class TestRunner(unittest.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue