mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 11:58:43 +00:00
Make docker_host and cli_context mutually exclusive. (#895)
This commit is contained in:
parent
36dcb94b39
commit
ad9d362336
2
changelogs/fragments/895-docker-cli.yml
Normal file
2
changelogs/fragments/895-docker-cli.yml
Normal file
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- "docker_compose_v2*, docker_stack*, docker_image_build modules - using ``cli_context`` no longer leads to an invalid parameter combination being passed to the corresponding Docker CLI tool, unless ``docker_host`` is also provided. Combining ``cli_context`` and ``docker_host`` is no longer allowed (https://github.com/ansible-collections/community.docker/issues/892, https://github.com/ansible-collections/community.docker/pull/895)."
|
||||
@ -318,8 +318,9 @@ options:
|
||||
the module will automatically replace C(tcp) in the connection URL with C(https).
|
||||
- If the value is not specified in the task, the value of environment variable E(DOCKER_HOST) will be used
|
||||
instead. If the environment variable is not set, the default value will be used.
|
||||
- Mutually exclusive with O(cli_context). If neither O(docker_host) nor O(cli_context) are provided, the
|
||||
value V(unix:///var/run/docker.sock) is used.
|
||||
type: str
|
||||
default: unix:///var/run/docker.sock
|
||||
aliases: [ docker_url ]
|
||||
tls_hostname:
|
||||
description:
|
||||
@ -381,6 +382,7 @@ options:
|
||||
cli_context:
|
||||
description:
|
||||
- The Docker CLI context to use.
|
||||
- Mutually exclusive with O(docker_host).
|
||||
type: str
|
||||
|
||||
notes:
|
||||
|
||||
@ -30,7 +30,7 @@ from ansible_collections.community.docker.plugins.module_utils.util import ( #
|
||||
|
||||
DOCKER_COMMON_ARGS = dict(
|
||||
docker_cli=dict(type='path'),
|
||||
docker_host=dict(type='str', default=DEFAULT_DOCKER_HOST, fallback=(env_fallback, ['DOCKER_HOST']), aliases=['docker_url']),
|
||||
docker_host=dict(type='str', fallback=(env_fallback, ['DOCKER_HOST']), aliases=['docker_url']),
|
||||
tls_hostname=dict(type='str', fallback=(env_fallback, ['DOCKER_TLS_HOSTNAME'])),
|
||||
api_version=dict(type='str', default='auto', fallback=(env_fallback, ['DOCKER_API_VERSION']), aliases=['docker_api_version']),
|
||||
ca_path=dict(type='path', aliases=['ca_cert', 'tls_ca_cert', 'cacert_path']),
|
||||
@ -62,7 +62,11 @@ class AnsibleDockerClientBase(object):
|
||||
self.fail('Cannot find docker CLI in path. Please provide it explicitly with the docker_cli parameter')
|
||||
|
||||
self._cli_base = [self._cli]
|
||||
self._cli_base.extend(['--host', common_args['docker_host']])
|
||||
docker_host = common_args['docker_host']
|
||||
if not docker_host and not common_args['cli_context']:
|
||||
docker_host = DEFAULT_DOCKER_HOST
|
||||
if docker_host:
|
||||
self._cli_base.extend(['--host', docker_host])
|
||||
if common_args['validate_certs']:
|
||||
self._cli_base.append('--tlsverify')
|
||||
elif common_args['tls']:
|
||||
@ -275,7 +279,7 @@ class AnsibleModuleDockerClient(AnsibleDockerClientBase):
|
||||
merged_arg_spec.update(argument_spec)
|
||||
self.arg_spec = merged_arg_spec
|
||||
|
||||
mutually_exclusive_params = []
|
||||
mutually_exclusive_params = [('docker_host', 'cli_context')]
|
||||
mutually_exclusive_params += DOCKER_MUTUALLY_EXCLUSIVE
|
||||
if mutually_exclusive:
|
||||
mutually_exclusive_params += mutually_exclusive
|
||||
|
||||
Loading…
Reference in New Issue
Block a user