mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-02 14:29:10 -07:00
Remove the -D module debug flag, which no longer is functional due to sudo pty requirements, and replace with -v/--verbose.
This flag will show playbook output from non-failing commands. -v is also added to /usr/bin/ansible, but not yet used. I also gutted some internals code dealing with 'invocations' which allowed the callback to know what module invoked it. This is not something 0.5 does or needed, so callbacks have been simplified.
This commit is contained in:
parent
9efea6f7a2
commit
efac68b636
12 changed files with 34 additions and 55 deletions
|
@ -132,14 +132,10 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks):
|
|||
self._async_notified = {}
|
||||
|
||||
def on_failed(self, host, res):
|
||||
invocation = res.get('invocation','')
|
||||
if not invocation.startswith('async_status'):
|
||||
self._on_any(host,res)
|
||||
self._on_any(host,res)
|
||||
|
||||
def on_ok(self, host, res):
|
||||
invocation = res.get('invocation','')
|
||||
if not invocation.startswith('async_status'):
|
||||
self._on_any(host,res)
|
||||
self._on_any(host,res)
|
||||
|
||||
def on_unreachable(self, host, res):
|
||||
if type(res) == dict:
|
||||
|
@ -180,28 +176,23 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks):
|
|||
class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
|
||||
''' callbacks used for Runner() from /usr/bin/ansible-playbook '''
|
||||
|
||||
def __init__(self, stats):
|
||||
def __init__(self, stats, verbose=False):
|
||||
self.stats = stats
|
||||
self._async_notified = {}
|
||||
self.verbose = verbose
|
||||
|
||||
def on_unreachable(self, host, msg):
|
||||
print "fatal: [%s] => %s" % (host, msg)
|
||||
|
||||
def on_failed(self, host, results):
|
||||
invocation = results.get('invocation',None)
|
||||
if not invocation or invocation.startswith('setup ') or invocation.startswith('async_status '):
|
||||
print "failed: [%s] => %s\n" % (host, utils.smjson(results))
|
||||
else:
|
||||
print "failed: [%s] => %s => %s\n" % (host, invocation, utils.smjson(results))
|
||||
print "failed: [%s] => %s\n" % (host, utils.smjson(results))
|
||||
|
||||
def on_ok(self, host, host_result):
|
||||
invocation = host_result.get('invocation','')
|
||||
if invocation.startswith('async_status'):
|
||||
pass
|
||||
elif not invocation or invocation.startswith('setup '):
|
||||
# show verbose output for non-setup module results if --verbose is used
|
||||
if not self.verbose or host_result.get("verbose_override",None) is not None:
|
||||
print "ok: [%s]\n" % (host)
|
||||
else:
|
||||
print "ok: [%s] => %s\n" % (host, invocation)
|
||||
print "ok: [%s] => %s" % (host, utils.smjson(host_result))
|
||||
|
||||
def on_error(self, host, err):
|
||||
print >>sys.stderr, "err: [%s] => %s\n" % (host, err)
|
||||
|
@ -230,8 +221,8 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
|
|||
class PlaybookCallbacks(object):
|
||||
''' playbook.py callbacks used by /usr/bin/ansible-playbook '''
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self, verbose=False):
|
||||
self.verbose = verbose
|
||||
|
||||
def on_start(self):
|
||||
print "\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue