Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add yes parameter to docker compose up #1045

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

londondaintta
Copy link

@londondaintta londondaintta commented Feb 21, 2025

SUMMARY

Add a variable for the docker compose up parameter yes to assume "yes" as answer to all prompts and run non-interactively. This prevents issues where the module hangs if a volume spec changes in the compose file.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

docker_compose_v2

ADDITIONAL INFORMATION
    - name: Start compose environment with yes
      community.docker.docker_compose_v2:
        project_src: compose
        assume_yes: true
        state: present

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

The integration test failures are unrelated, the nightly tests were failing as well. (This started yesterday, after the release of Docker Compose 2.33.0.)

The --yes option was added in Compose 2.32.0 (docker/compose#12363).

@@ -160,6 +160,12 @@
- 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.
Copy link
Collaborator

@felixfontein felixfontein Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- When O(yes=true), pass C(--yes) to assume "yes" as answer to all prompts and run non-interactively.
- When O(yes=true), pass 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(yes=false)
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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

results in the question being answered by "no" is not quite right. It actually causes the command to hang as it waits for stdin.

@@ -160,6 +160,12 @@
- When O(wait=true), wait at most this amount of seconds.
type: int
version_added: 3.8.0
yes:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure yes is a good option name. One problem is that "yes" is a YAML 1.1 boolean value, so it will require quoting the option to be able to use it (unless Ansible does some magic).

How about approve_questions or something like that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a good point. Perhaps assume_yes is a little more obvious?

@felixfontein felixfontein added the docker-compose-v2 Docker Compose v2 label Feb 21, 2025
@felixfontein
Copy link
Collaborator

Could you also add a check to __init__() that self.compose_version >= LooseVersion('2.32.0') when the option is set to true (you'll need from ansible_collections.community.docker.plugins.module_utils.version import LooseVersion)?

@felixfontein
Copy link
Collaborator

The integration test failures are unrelated, the nightly tests were failing as well. (This started yesterday, after the release of Docker Compose 2.33.0.)

The problem is actually Docker CLI 28.0.0, which generates some unexpected stderr output. This has been fixed in docker/cli#5854, I hope there will be a bugfix release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker-compose-v2 Docker Compose v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants