add yes option for compose up to assume yes and prevent hanging

This commit is contained in:
Dominic London 2025-02-21 12:33:22 +00:00 committed by Dominic London
parent f99a9b618c
commit a6fcdfc3e0

View File

@ -160,6 +160,11 @@ options:
- When O(wait=true), wait at most this amount of seconds.
type: int
version_added: 3.8.0
yes:
description:
- When O(yes=true), pass C(--yes) to assume "yes" as answer to all prompts and run non-interactively.
type: int
version_added: TODO
author:
- Felix Fontein (@felixfontein)
@ -465,6 +470,7 @@ class ServicesManager(BaseComposeManager):
self.scale = parameters['scale'] or {}
self.wait = parameters['wait']
self.wait_timeout = parameters['wait_timeout']
self.yes = parameters['yes']
for key, value in self.scale.items():
if not isinstance(key, string_types):
@ -522,6 +528,8 @@ class ServicesManager(BaseComposeManager):
args.append('--no-start')
if dry_run:
args.append('--dry-run')
if self.yes:
args.append('--yes')
args.append('--')
for service in self.services:
args.append(service)
@ -656,6 +664,7 @@ def main():
wait=dict(type='bool', default=False),
wait_timeout=dict(type='int'),
ignore_build_events=dict(type='bool', default=True),
yes=dict(type='bool', default=False),
)
argspec_ex = common_compose_argspec_ex()
argument_spec.update(argspec_ex.pop('argspec'))