@ -2211,20 +2211,25 @@ class ContainerManager(DockerBaseClass):
status = self . client . wait ( container_id ) [ ' StatusCode ' ]
status = self . client . wait ( container_id ) [ ' StatusCode ' ]
else :
else :
status = self . client . wait ( container_id )
status = self . client . wait ( container_id )
config = self . client . inspect_container ( container_id )
if self . parameters . auto_remove :
logging_driver = config [ ' HostConfig ' ] [ ' LogConfig ' ] [ ' Type ' ]
output = " Cannot retrieve result as auto_remove is enabled "
if logging_driver == ' json-file ' or logging_driver == ' journald ' :
output = self . client . logs ( container_id , stdout = True , stderr = True , stream = False , timestamps = False )
if self . parameters . output_logs :
if self . parameters . output_logs :
self . _output_logs( msg = output )
self . client . module . warn ( ' Cannot output_logs if auto_remove is enabled! ' )
else :
else :
output = " Result logged using ` %s ` driver " % logging_driver
config = self . client . inspect_container ( container_id )
logging_driver = config [ ' HostConfig ' ] [ ' LogConfig ' ] [ ' Type ' ]
if logging_driver == ' json-file ' or logging_driver == ' journald ' :
output = self . client . logs ( container_id , stdout = True , stderr = True , stream = False , timestamps = False )
if self . parameters . output_logs :
self . _output_logs ( msg = output )
else :
output = " Result logged using ` %s ` driver " % logging_driver
if status != 0 :
if status != 0 :
self . fail ( output , status = status )
self . fail ( output , status = status )
if self . parameters . cleanup :
if self . parameters . cleanup :
self . container_remove ( container_id , force = True )
self . container_remove ( container_id , force = True , ignore_failure = self . parameters . auto_remove )
insp = self . _get_container ( container_id )
insp = self . _get_container ( container_id )
if insp . raw :
if insp . raw :
insp . raw [ ' Output ' ] = output
insp . raw [ ' Output ' ] = output
@ -2233,7 +2238,7 @@ class ContainerManager(DockerBaseClass):
return insp
return insp
return self . _get_container ( container_id )
return self . _get_container ( container_id )
def container_remove ( self , container_id , link = False , force = False ):
def container_remove ( self , container_id , link = False , force = False , ignore_failure = False ):
volume_state = ( not self . parameters . keep_volumes )
volume_state = ( not self . parameters . keep_volumes )
self . log ( " remove container container: %s v: %s link: %s force %s " % ( container_id , volume_state , link , force ) )
self . log ( " remove container container: %s v: %s link: %s force %s " % ( container_id , volume_state , link , force ) )
self . results [ ' actions ' ] . append ( dict ( removed = container_id , volume_state = volume_state , link = link , force = force ) )
self . results [ ' actions ' ] . append ( dict ( removed = container_id , volume_state = volume_state , link = link , force = force ) )
@ -2243,7 +2248,8 @@ class ContainerManager(DockerBaseClass):
try :
try :
response = self . client . remove_container ( container_id , v = volume_state , link = link , force = force )
response = self . client . remove_container ( container_id , v = volume_state , link = link , force = force )
except Exception as exc :
except Exception as exc :
self . fail ( " Error removing container %s : %s " % ( container_id , str ( exc ) ) )
if not ignore_failure :
self . fail ( " Error removing container %s : %s " % ( container_id , str ( exc ) ) )
return response
return response
def container_update ( self , container_id , update_parameters ) :
def container_update ( self , container_id , update_parameters ) :