diff --git a/changelogs/fragments/1226-docker-sdk-tls.yml b/changelogs/fragments/1226-docker-sdk-tls.yml new file mode 100644 index 00000000..b99599dc --- /dev/null +++ b/changelogs/fragments/1226-docker-sdk-tls.yml @@ -0,0 +1,2 @@ +bugfixes: + - "modules and plugins using the Docker SDK for Python - do not automatically set ``tls_hostname`` when ``validate_certs=true`` for Docker SDK for Python 7.0.0+ (https://github.com/ansible-collections/community.docker/issues/1225, https://github.com/ansible-collections/community.docker/pull/1226)." diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index 57b10e88..c3db88da 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -160,9 +160,10 @@ def get_connect_params(auth, fail_function): # TLS with verification tls_config = dict( verify=True, - assert_hostname=auth['tls_hostname'], fail_function=fail_function, ) + if auth["tls_hostname"] is not None: + tls_config["assert_hostname"] = auth["tls_hostname"] if auth['cert_path'] and auth['key_path']: tls_config['client_cert'] = (auth['cert_path'], auth['key_path']) if auth['cacert_path']: @@ -327,7 +328,8 @@ class AnsibleDockerClientBase(Client): use_ssh_client=self._get_value('use_ssh_client', params['use_ssh_client'], None, False, type='bool'), ) - update_tls_hostname(result) + if LooseVersion(docker_version) < LooseVersion("7.0.0b1"): + update_tls_hostname(result) return result