mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-04-07 18:53:08 +00:00
feat: add docker-compose services support. (#758)
* feat: add docker-compose services support. fix: typo * fix: error * fix: ci Job * feat: add argument_spec * fix: whitespace * feat: refactored docker_compose_v2 in response to feedback
This commit is contained in:
parent
ab73061a5f
commit
98a74b1f9c
@ -99,6 +99,11 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Timeout in seconds for container shutdown when attached or when containers are already running.
|
- Timeout in seconds for container shutdown when attached or when containers are already running.
|
||||||
type: int
|
type: int
|
||||||
|
services:
|
||||||
|
description:
|
||||||
|
- Specifies a subset of services to be targeted.
|
||||||
|
type: list
|
||||||
|
elements: str
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
- "Docker CLI with Docker compose plugin 2.18.0 or later"
|
- "Docker CLI with Docker compose plugin 2.18.0 or later"
|
||||||
@ -399,6 +404,7 @@ class ServicesManager(BaseComposeManager):
|
|||||||
self.remove_volumes = parameters['remove_volumes']
|
self.remove_volumes = parameters['remove_volumes']
|
||||||
self.remove_orphans = parameters['remove_orphans']
|
self.remove_orphans = parameters['remove_orphans']
|
||||||
self.timeout = parameters['timeout']
|
self.timeout = parameters['timeout']
|
||||||
|
self.services = parameters['services'] or []
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.state == 'present':
|
if self.state == 'present':
|
||||||
@ -433,6 +439,8 @@ class ServicesManager(BaseComposeManager):
|
|||||||
args.append('--no-start')
|
args.append('--no-start')
|
||||||
if dry_run:
|
if dry_run:
|
||||||
args.append('--dry-run')
|
args.append('--dry-run')
|
||||||
|
for service in self.services:
|
||||||
|
args.append(service)
|
||||||
args.append('--')
|
args.append('--')
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@ -452,6 +460,8 @@ class ServicesManager(BaseComposeManager):
|
|||||||
args.extend(['--timeout', '%d' % self.timeout])
|
args.extend(['--timeout', '%d' % self.timeout])
|
||||||
if dry_run:
|
if dry_run:
|
||||||
args.append('--dry-run')
|
args.append('--dry-run')
|
||||||
|
for service in self.services:
|
||||||
|
args.append(service)
|
||||||
args.append('--')
|
args.append('--')
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@ -503,6 +513,8 @@ class ServicesManager(BaseComposeManager):
|
|||||||
args.extend(['--timeout', '%d' % self.timeout])
|
args.extend(['--timeout', '%d' % self.timeout])
|
||||||
if dry_run:
|
if dry_run:
|
||||||
args.append('--dry-run')
|
args.append('--dry-run')
|
||||||
|
for service in self.services:
|
||||||
|
args.append(service)
|
||||||
args.append('--')
|
args.append('--')
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@ -528,6 +540,8 @@ class ServicesManager(BaseComposeManager):
|
|||||||
args.extend(['--timeout', '%d' % self.timeout])
|
args.extend(['--timeout', '%d' % self.timeout])
|
||||||
if dry_run:
|
if dry_run:
|
||||||
args.append('--dry-run')
|
args.append('--dry-run')
|
||||||
|
for service in self.services:
|
||||||
|
args.append(service)
|
||||||
args.append('--')
|
args.append('--')
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@ -552,6 +566,7 @@ def main():
|
|||||||
remove_volumes=dict(type='bool', default=False),
|
remove_volumes=dict(type='bool', default=False),
|
||||||
remove_orphans=dict(type='bool', default=False),
|
remove_orphans=dict(type='bool', default=False),
|
||||||
timeout=dict(type='int'),
|
timeout=dict(type='int'),
|
||||||
|
services=dict(type='list', elements='str'),
|
||||||
)
|
)
|
||||||
argument_spec.update(common_compose_argspec())
|
argument_spec.update(common_compose_argspec())
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user