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_swarm_service: Extend env and add env_files support #51762
docker_swarm_service: Extend env and add env_files support #51762
Conversation
The test
|
|
Ah yes, I somehow mixed that up. Unfortunately the |
You can always access it via |
The
Since only I guess that don't really need the int / float handling made in Edit: I made a commit which should make it a bit clearer. |
changelogs/fragments/51762-docker_swarm_service-extend-env-and-add-env-file.yml
Outdated
Show resolved
Hide resolved
@@ -769,7 +825,7 @@ def compare(self, os): | |||
force_update = False | |||
if self.endpoint_mode is not None and self.endpoint_mode != os.endpoint_mode: | |||
differences.add('endpoint_mode', parameter=self.endpoint_mode, active=os.endpoint_mode) | |||
if self.env != os.env: | |||
if self.env is not None and self.env != os.env: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.env
will never be None
, it will always be a dict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm can it not be None
from ansible parameters?
If no environment is parsed into env_list
in get_docker_environment
it will default to None
:
https://github.com/hannseman/ansible/blob/68a2543f0bd0d2d44ef16b2575c43760e52aebd5/lib/ansible/modules/cloud/docker/docker_swarm_service.py#L600
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I apparently completely missed the or None
. Yes, you are totally right!
Co-Authored-By: hannseman <hannes@5monkeys.se>
2c347ee
to
e3e5446
Compare
LGTM |
shipit |
shipit |
bot_status |
Componentschangelogs/fragments/51762-docker_swarm_service-extend-env-and-add-env-file.yml lib/ansible/modules/cloud/docker/docker_swarm_service.py test/integration/targets/docker_swarm_service/files/env-file-1 test/integration/targets/docker_swarm_service/files/env-file-2 test/integration/targets/docker_swarm_service/tasks/tests/options.yml test/units/modules/cloud/docker/test_docker_swarm_service.py Metadatawaiting_on: maintainer |
@hannseman Thank you for the PR Merged into |
Thanks everyone! :) |
SUMMARY
This PR adds the possibility the specify
env
as a dict.It also adds a new option called
env_files
which accepts a list of paths to env-files.The order in this list matters where the last file will override variables already defined in previous files. It is useful for sharing env-files for different environments where a common file with defaults can be overridden by an environment specific file.
I chose to not map the behaviour of
env_files
to the docker-compose equivalent calledenv_file
which accepts both a list and a string. Then we could not rely on the argument specpath
type validation but would be required to implement our own validation that the specified files exist.ISSUE TYPE
COMPONENT NAME
docker_swarm_service