mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-17 12:28:55 +00:00
docker_compose_v2: use --yes when available instead of -y (#1060)
* Use --yes if available. * Add smoke test.
This commit is contained in:
parent
c13b891bc9
commit
635716c07b
2
changelogs/fragments/1060-compose-yes.yml
Normal file
2
changelogs/fragments/1060-compose-yes.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "docker_compose_v2 - use ``--yes`` instead of ``-y`` from Docker Compose 2.34.0 on (https://github.com/ansible-collections/community.docker/pull/1060)."
|
||||||
@ -162,7 +162,7 @@ options:
|
|||||||
version_added: 3.8.0
|
version_added: 3.8.0
|
||||||
assume_yes:
|
assume_yes:
|
||||||
description:
|
description:
|
||||||
- When O(assume_yes=true), pass C(-y) to assume "yes" as answer to all prompts and run non-interactively.
|
- When O(assume_yes=true), pass C(-y)/C(--yes) to assume "yes" as answer to all prompts and run non-interactively.
|
||||||
- Right now a prompt is asked whenever a non-matching volume should be re-created. O(assume_yes=false)
|
- Right now a prompt is asked whenever a non-matching volume should be re-created. O(assume_yes=false)
|
||||||
results in the question being answered by "no", which will simply re-use the existing volume.
|
results in the question being answered by "no", which will simply re-use the existing volume.
|
||||||
- This option is only available on Docker Compose 2.32.0 or newer.
|
- This option is only available on Docker Compose 2.32.0 or newer.
|
||||||
@ -537,8 +537,9 @@ class ServicesManager(BaseComposeManager):
|
|||||||
if dry_run:
|
if dry_run:
|
||||||
args.append('--dry-run')
|
args.append('--dry-run')
|
||||||
if self.yes:
|
if self.yes:
|
||||||
# Note that the long form is '--y', and not '--yes' as one would expect. Since this looks like a bug we're using the short form.
|
# Note that for Docker Compose 2.32.x and 2.33.x, the long form is '--y' and not '--yes'.
|
||||||
args.append('-y')
|
# This was fixed in Docker Compose 2.34.0 (https://github.com/docker/compose/releases/tag/v2.34.0).
|
||||||
|
args.append('-y' if self.compose_version < LooseVersion('2.34.0') else '--yes')
|
||||||
args.append('--')
|
args.append('--')
|
||||||
for service in self.services:
|
for service in self.services:
|
||||||
args.append(service)
|
args.append(service)
|
||||||
|
|||||||
@ -84,6 +84,13 @@
|
|||||||
state: present
|
state: present
|
||||||
register: present_3
|
register: present_3
|
||||||
|
|
||||||
|
- name: Present with --yes
|
||||||
|
docker_compose_v2:
|
||||||
|
project_src: '{{ project_src }}'
|
||||||
|
state: present
|
||||||
|
assume_yes: true
|
||||||
|
when: docker_compose_version is version('2.32.0', '>=')
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- present_1_check is changed
|
- present_1_check is changed
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user