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 renew_anon_volumes parameter to docker compose up #977

Merged
merged 5 commits into from
Oct 19, 2024

Conversation

z-bsod
Copy link
Contributor

@z-bsod z-bsod commented Oct 17, 2024

SUMMARY

Add a variable for the docker compose up parameter renew_anon_volumes to recreate anonymous volumes when recreating containers on docker compose up

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

docker_compose_v2

ADDITIONAL INFORMATION

As far as I am aware there was no way to set this option using the community.docker collection before

usage example:

    - name: Start compose environment and renew anon volumes
      community.docker.docker_compose_v2:
        project_src: compose
        renew_anon_volumes: true
        state: present

output of example playbook in test repository

% ansible-playbook test.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match
'all'

PLAY [localhost] ******************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************
ok: [localhost]

TASK [Build images] ***************************************************************************************************
ok: [localhost] => (item=1)
ok: [localhost] => (item=2)
ok: [localhost] => (item=3)

TASK [Start compose with image version 1] *****************************************************************************
changed: [localhost]

TASK [create file in image] *******************************************************************************************
changed: [localhost]

TASK [get folder contents] ********************************************************************************************
changed: [localhost]

TASK [Output folder contents] *****************************************************************************************
ok: [localhost] => {
    "folder.stdout": "total 0\n-rw-r--r-- 1 root root 0 Oct 17 06:51 image_v1"
}

TASK [start image with image version 2] *******************************************************************************
changed: [localhost]

TASK [get folder contents of v2 container] ****************************************************************************
changed: [localhost]

TASK [Output folder contents] *****************************************************************************************
ok: [localhost] => {
    "folder.stdout": "total 0\n-rw-r--r-- 1 root root 0 Oct 17 06:51 image_v1"
}

TASK [start image with image version 3 and cleanup parameter] *********************************************************
changed: [localhost]

TASK [get folder contents of v3 container] ****************************************************************************
changed: [localhost]

TASK [Output folder contents] *****************************************************************************************
ok: [localhost] => {
    "folder.stdout": "total 0"
}

PLAY RECAP ************************************************************************************************************
localhost                  : ok=12   changed=7    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

ansible-playbook test.yml  4,59s user 2,84s system 25% cpu 28,629 total
 

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! Can you please add a changelog fragment? Thanks.

plugins/modules/docker_compose_v2.py Show resolved Hide resolved
plugins/modules/docker_compose_v2.py Outdated Show resolved Hide resolved
plugins/modules/docker_compose_v2.py Outdated Show resolved Hide resolved
z-bsod and others added 2 commits October 18, 2024 15:44
Apply suggested changes to Documentation

Co-authored-by: Felix Fontein <[email protected]>
apply suggestion from code review

Co-authored-by: Felix Fontein <[email protected]>
@felixfontein
Copy link
Collaborator

Thanks for applying the changes. Please do not forget about the changelog fragment :)

@z-bsod
Copy link
Contributor Author

z-bsod commented Oct 19, 2024

Ah, I misunderstood and thought the version number in the Documentation was a changelog fragment.

After looking up what a changelog fragment is, I added one and hope it's correct this way.

@felixfontein felixfontein merged commit be5564d into ansible-collections:main Oct 19, 2024
78 checks passed
@felixfontein
Copy link
Collaborator

@z-bsod thanks for your contribution! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants