-
Notifications
You must be signed in to change notification settings - Fork 122
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
docker_secret.py: use secret versioning to avoid secret deletion on update #21
Comments
/cc @chouseknecht (who I see is the flagged author for this module) |
Is this an official recommendation how to do versioning with docker swarm secrets, or your own scheme? If the second, I'm not sure whether it should be part of the docker_secret module. Maybe a separate module? (And I guess the same is true for |
It's the recommended practical approach, see moby/moby#29882 (comment) and the rest of the ticket. Also see https://blog.viktoradam.net/2018/02/28/swarm-secrets-made-easy/. |
If you have to specify the version as a label, why not simply template the secret's name in the |
If you ever change the data the module will delete and re-create the secret in place regardless of what the name is versioned as. If we could just had a way to flick that functionality off then the name versioning could work, I guess. |
So if your change is implemented, you expect the module to fail if you changed the secret without bumping the version manually? |
Please describe the exact difference between what you envision - name: Change the secret data
docker_secret:
name: foo
data: bar
version: true
labels:
version: "1"
state: present would do, and what - name: Change the secret data
docker_secret:
name: foo-v1
data: bar
labels:
version: "1"
state: present does. |
SUMMARY
The current functionality of docker_secret.py is that when an update to a secret is discovered the existing secret is deleted and the new one is created. This is not ideal since current best practice is to preserve all secret values and increment a version or some other similar metadata to update to a following value. Docker secrets are immutable so deleting them and replacing them breaks their guarantee for rollback scenarios.
I'd like to propose that we retain the existing functionality of delete/replace of updated secrets to not break existing playbooks. Then, add a new module level option, say,
version: true/false
which expects to find aversion: "1"
key/val pair in thelabels
dictionary. Then if you have a secret withname: foo
andlabels: version: "1"
the module will create an underlying secret with the name offoo-v1
. Once you changeversion: "2"
then you will get afoo-v2
andfoo-v1
will still be there that can be used to ensure previous configurations work.It may be that we need to expose a
FOO_VERSION
variable of some sort to tie this into thedocker-compose.yml
file where we have aname: foo-${FOO_VERSION}
key/val on thesecrets
definition?I haven't look deeply at the code but I hope this can be done without breaking changes.
ISSUE TYPE
COMPONENT NAME
docker_secret
ADDITIONAL INFORMATION
Here is an example task.
The text was updated successfully, but these errors were encountered: