From 2af851af56036b3d21ee0e4d785800c6339ffe30 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Mon, 8 Jun 2026 11:21:48 +0800 Subject: [PATCH] fix(accounts): support new gateway proxy layout in ssh ping (#16895) Co-authored-by: Crane.z <1481445951@qq.com> --- apps/libs/ansible/modules_utils/remote_client.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/libs/ansible/modules_utils/remote_client.py b/apps/libs/ansible/modules_utils/remote_client.py index 71a74aca2..6f7c6549a 100644 --- a/apps/libs/ansible/modules_utils/remote_client.py +++ b/apps/libs/ansible/modules_utils/remote_client.py @@ -79,6 +79,15 @@ def _strip_wrapping_quotes(value): return value +def normalize_gateway_args_for_legacy_parser(gateway_args): + + return re.sub( + r'(-W\s+%h:%p\s+-q)\s+--\s+([^@\s]+@[^\'"\s]+)([\'"]?)', + r'\2 \1\3', + gateway_args, + ) + + class OldSSHTransport(paramiko.transport.Transport): _preferred_pubkeys = ( "ssh-ed25519", @@ -268,6 +277,7 @@ class SSHClient: def local_gateway_prepare(self): gateway_args = self.module.params['gateway_args'] or '' + gateway_args = normalize_gateway_args_for_legacy_parser(gateway_args) pattern = ( r"(?:sshpass -p ([^ ]+))?\s*ssh -o Port=(\d+)\s+-o StrictHostKeyChecking=no\s+" r"([^@\s]+)@([^\s]+)\s+-W %h:%p -q(?: -i ([^']+))?'"