Add support for rotating docker configs #295
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
Add support for rolling updates for docker configs. Based on the same functionality for secrets in #293.
Adding two additional parameters for the
docker_config
module:rolling_versions
(default: false): whether to use versioning configs for rolling updates.versions_to_keep
(default: 5): when using rolling updates, how many of the old versions to keep.When
rolling_versions
is set totrue
configs are created with a_vX
postfix in their names whereX
is replaced with an incremental counter. That counter is also added to the configs as a label with the name ofansible_version
. This way when a config is changed a new version is created with an incremented version number instead of deleting it first then creating again. This aims to solve the problem where the config is attached to a service, thus deleting it fails.This is the recommended approach of updating configs based on the official Docker documentation.
The change is not breaking, users of this module shouldn't expect any changes.
ISSUE TYPE
COMPONENT NAME
docker_config
ADDITIONAL INFORMATION
The problem this PR aims to solve is the following:
When a config is attached to a service docker won't let it get deleted, thus the current version of the module fails execution if one tries to update a config that is attached to a service already. The recommendation from docker for this is to create a new config with the updated data then update the service definition adding the new config in place of the old one. Afterwards the old config can be safely deleted. Having different names for the config is a non-issue since one can define the mountpoint for the config in the container regardless of its name.
The PR addresses #109