diff --git a/changelogs/fragments/ansible-test-docker-forwards.yml b/changelogs/fragments/ansible-test-docker-forwards.yml new file mode 100644 index 00000000000..6da14b030c2 --- /dev/null +++ b/changelogs/fragments/ansible-test-docker-forwards.yml @@ -0,0 +1,5 @@ +bugfixes: +- ansible-test - Properly detect docker host when using ``ssh://`` protocol for connecting to the docker daemon. +- ansible-test - Explicitly supply ``ControlPath=none`` when setting up port fowarding over SSH to address + the scenario where the local ssh configuration uses ``ControlPath`` for all hosts, and would prevent + ports to be forwarded after the initial connection to the host. diff --git a/test/lib/ansible_test/_internal/docker_util.py b/test/lib/ansible_test/_internal/docker_util.py index 52b9691ed51..97c022c1de7 100644 --- a/test/lib/ansible_test/_internal/docker_util.py +++ b/test/lib/ansible_test/_internal/docker_util.py @@ -496,7 +496,7 @@ def get_docker_hostname() -> str: """Return the hostname of the Docker service.""" docker_host = os.environ.get('DOCKER_HOST') - if docker_host and docker_host.startswith('tcp://'): + if docker_host and docker_host.startswith(('tcp://', 'ssh://')): try: hostname = urllib.parse.urlparse(docker_host)[1].split(':')[0] display.info('Detected Docker host: %s' % hostname, verbosity=1) diff --git a/test/lib/ansible_test/_internal/ssh.py b/test/lib/ansible_test/_internal/ssh.py index b2a267873ac..812576808e6 100644 --- a/test/lib/ansible_test/_internal/ssh.py +++ b/test/lib/ansible_test/_internal/ssh.py @@ -245,6 +245,7 @@ def create_ssh_port_forwards( """ options: dict[str, t.Union[str, int]] = dict( LogLevel='INFO', # info level required to get messages on stderr indicating the ports assigned to each forward + ControlPath='none', # if the user has ControlPath set up for every host, it will prevent creation of forwards ) cli_args = []