@ -132,14 +132,10 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks):
self . _async_notified = { }
self . _async_notified = { }
def on_failed ( self , host , res ) :
def on_failed ( self , host , res ) :
invocation = res . get ( ' invocation ' , ' ' )
self . _on_any ( host , res )
if not invocation . startswith ( ' async_status ' ) :
self . _on_any ( host , res )
def on_ok ( self , host , res ) :
def on_ok ( self , host , res ) :
invocation = res . get ( ' invocation ' , ' ' )
self . _on_any ( host , res )
if not invocation . startswith ( ' async_status ' ) :
self . _on_any ( host , res )
def on_unreachable ( self , host , res ) :
def on_unreachable ( self , host , res ) :
if type ( res ) == dict :
if type ( res ) == dict :
@ -180,28 +176,23 @@ class CliRunnerCallbacks(DefaultRunnerCallbacks):
class PlaybookRunnerCallbacks ( DefaultRunnerCallbacks ) :
class PlaybookRunnerCallbacks ( DefaultRunnerCallbacks ) :
''' callbacks used for Runner() from /usr/bin/ansible-playbook '''
''' callbacks used for Runner() from /usr/bin/ansible-playbook '''
def __init__ ( self , stats ):
def __init__ ( self , stats , verbose = False ):
self . stats = stats
self . stats = stats
self . _async_notified = { }
self . _async_notified = { }
self . verbose = verbose
def on_unreachable ( self , host , msg ) :
def on_unreachable ( self , host , msg ) :
print " fatal: [ %s ] => %s " % ( host , msg )
print " fatal: [ %s ] => %s " % ( host , msg )
def on_failed ( self , host , results ) :
def on_failed ( self , host , results ) :
invocation = results . get ( ' invocation ' , None )
print " failed: [ %s ] => %s \n " % ( host , utils . smjson ( results ) )
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 ) )
def on_ok ( self , host , host_result ) :
def on_ok ( self , host , host_result ) :
invocation = host_result . get ( ' invocation ' , ' ' )
# show verbose output for non-setup module results if --verbose is used
if invocation . startswith ( ' async_status ' ) :
if not self . verbose or host_result . get ( " verbose_override " , None ) is not None :
pass
elif not invocation or invocation . startswith ( ' setup ' ) :
print " ok: [ %s ] \n " % ( host )
print " ok: [ %s ] \n " % ( host )
else :
else :
print " ok: [ %s ] => %s \n " % ( host , invocation )
print " ok: [ %s ] => %s " % ( host , utils. smjson ( host_result ) )
def on_error ( self , host , err ) :
def on_error ( self , host , err ) :
print >> sys . stderr , " err: [ %s ] => %s \n " % ( host , err )
print >> sys . stderr , " err: [ %s ] => %s \n " % ( host , err )
@ -230,8 +221,8 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
class PlaybookCallbacks ( object ) :
class PlaybookCallbacks ( object ) :
''' playbook.py callbacks used by /usr/bin/ansible-playbook '''
''' playbook.py callbacks used by /usr/bin/ansible-playbook '''
def __init__ ( self ):
def __init__ ( self , verbose = False ):
pass
self . verbose = verbose
def on_start ( self ) :
def on_start ( self ) :
print " \n "
print " \n "