Get rid of distutils.spawn. (#257)

This commit is contained in:
Felix Fontein 2021-12-24 11:27:23 +01:00 committed by GitHub
parent 40576e317b
commit 93ea131f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- "docker connection plugin - replace deprecated ``distutils.spawn.find_executable`` with Ansible's ``get_bin_path`` to find the ``docker`` executable (https://github.com/ansible-collections/community.docker/pull/257)."

View File

@ -41,7 +41,6 @@ DOCUMENTATION = '''
- name: ansible_docker_host
'''
import distutils.spawn
import fcntl
import os
import os.path
@ -54,6 +53,7 @@ import ansible.constants as C
from ansible.compat import selectors
from ansible.errors import AnsibleError, AnsibleFileNotFound
from ansible.module_utils.six.moves import shlex_quote
from ansible.module_utils.common.process import get_bin_path
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.plugins.connection import ConnectionBase, BUFSIZE
from ansible.utils.display import Display
@ -86,8 +86,9 @@ class Connection(ConnectionBase):
if 'docker_command' in kwargs:
self.docker_cmd = kwargs['docker_command']
else:
self.docker_cmd = distutils.spawn.find_executable('docker')
if not self.docker_cmd:
try:
self.docker_cmd = get_bin_path('docker')
except ValueError:
raise AnsibleError("docker command not found in PATH")
docker_version = self._get_docker_version()