Skip to content

Commit

Permalink
Get rid of distutils.spawn. (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein authored Dec 24, 2021
1 parent 40576e3 commit 93ea131
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/257-remove-distutils-spawn.yml
Original file line number Diff line number Diff line change
@@ -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)."
7 changes: 4 additions & 3 deletions plugins/connection/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
- name: ansible_docker_host
'''

import distutils.spawn
import fcntl
import os
import os.path
Expand All @@ -54,6 +53,7 @@
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
Expand Down Expand Up @@ -86,8 +86,9 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
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()
Expand Down

0 comments on commit 93ea131

Please sign in to comment.