mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-03-15 19:58:28 +00:00
Add wait and wait_timeout options. (#796)
This commit is contained in:
parent
b5de1fd1ad
commit
e494464e56
2
changelogs/fragments/796-docker_compose_v2-wait.yml
Normal file
2
changelogs/fragments/796-docker_compose_v2-wait.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
minor_changes:
|
||||||
|
- "docker_compose_v2 - allow to wait until containers are running/health when running ``docker compose up`` with the new ``wait`` option (https://github.com/ansible-collections/community.docker/issues/794, https://github.com/ansible-collections/community.docker/pull/796)."
|
||||||
@ -124,6 +124,18 @@ options:
|
|||||||
and the value is an integer count for the number of containers.
|
and the value is an integer count for the number of containers.
|
||||||
type: dict
|
type: dict
|
||||||
version_added: 3.7.0
|
version_added: 3.7.0
|
||||||
|
wait:
|
||||||
|
description:
|
||||||
|
- When running C(docker compose up), pass C(--wait) to wait for services to be running/healthy.
|
||||||
|
- A timeout can be set with the O(wait_timeout) option.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: 3.8.0
|
||||||
|
wait_timeout:
|
||||||
|
description:
|
||||||
|
- When O(wait=true), wait at most this amount of seconds.
|
||||||
|
type: int
|
||||||
|
version_added: 3.8.0
|
||||||
|
|
||||||
author:
|
author:
|
||||||
- Felix Fontein (@felixfontein)
|
- Felix Fontein (@felixfontein)
|
||||||
@ -416,6 +428,8 @@ class ServicesManager(BaseComposeManager):
|
|||||||
self.timeout = parameters['timeout']
|
self.timeout = parameters['timeout']
|
||||||
self.services = parameters['services'] or []
|
self.services = parameters['services'] or []
|
||||||
self.scale = parameters['scale'] or {}
|
self.scale = parameters['scale'] or {}
|
||||||
|
self.wait = parameters['wait']
|
||||||
|
self.wait_timeout = parameters['wait_timeout']
|
||||||
|
|
||||||
for key, value in self.scale.items():
|
for key, value in self.scale.items():
|
||||||
if not isinstance(key, string_types):
|
if not isinstance(key, string_types):
|
||||||
@ -463,6 +477,10 @@ class ServicesManager(BaseComposeManager):
|
|||||||
args.append('--no-build')
|
args.append('--no-build')
|
||||||
for key, value in sorted(self.scale.items()):
|
for key, value in sorted(self.scale.items()):
|
||||||
args.extend(['--scale', '%s=%d' % (key, value)])
|
args.extend(['--scale', '%s=%d' % (key, value)])
|
||||||
|
if self.wait:
|
||||||
|
args.append('--wait')
|
||||||
|
if self.wait_timeout is not None:
|
||||||
|
args.extend(['--wait-timeout', str(self.wait_timeout)])
|
||||||
if no_start:
|
if no_start:
|
||||||
args.append('--no-start')
|
args.append('--no-start')
|
||||||
if dry_run:
|
if dry_run:
|
||||||
@ -597,6 +615,8 @@ def main():
|
|||||||
timeout=dict(type='int'),
|
timeout=dict(type='int'),
|
||||||
services=dict(type='list', elements='str'),
|
services=dict(type='list', elements='str'),
|
||||||
scale=dict(type='dict'),
|
scale=dict(type='dict'),
|
||||||
|
wait=dict(type='bool', default=False),
|
||||||
|
wait_timeout=dict(type='int'),
|
||||||
)
|
)
|
||||||
argument_spec.update(common_compose_argspec())
|
argument_spec.update(common_compose_argspec())
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user