mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Wait for process exit on detached=no.
This commit is contained in:
parent
f9c294f1ad
commit
ea83727fcf
1 changed files with 9 additions and 1 deletions
|
@ -196,7 +196,8 @@ options:
|
|||
default: null
|
||||
detach:
|
||||
description:
|
||||
- Enable detached mode to leave the container running in background.
|
||||
- Enable detached mode to leave the container running in background. If
|
||||
disabled, fail unless the process exits cleanly.
|
||||
default: true
|
||||
state:
|
||||
description:
|
||||
|
@ -1346,6 +1347,13 @@ class DockerManager(object):
|
|||
self.client.start(i)
|
||||
self.increment_counter('started')
|
||||
|
||||
if not self.module.params.get('detach'):
|
||||
status = self.client.wait(i['Id'])
|
||||
if status != 0:
|
||||
output = self.client.logs(i['Id'], stdout=True, stderr=True,
|
||||
stream=False, timestamps=False)
|
||||
self.module.fail_json(status=status, msg=output)
|
||||
|
||||
def stop_containers(self, containers):
|
||||
for i in containers:
|
||||
self.client.stop(i['Id'])
|
||||
|
|
Loading…
Reference in a new issue