mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 12:03:58 -07:00
[PR #9795/96b49300 backport][stable-10] add the wsl connection plugin (#10019)
add the wsl connection plugin (#9795)
* add the wsl connection plugin
* move the banner_timeout required paramiko version to its own line
* document the proxy_command required paramiko version
* document the timeout required paramiko version
* simplify the sending of the become_pass value
* add Connection.__init__ type hints
* add MyAddPolicy.missing_host_key type hints
* normalize the Connection._parse_proxy_command replacers dict values to the str type
* add the user_known_hosts_file option
* modify the private_key_file option type to path
(cherry picked from commit 96b493002c
)
Co-authored-by: Rui Lopes <rgl@ruilopes.com>
This commit is contained in:
parent
91ac9f84b8
commit
ee2779e6c1
12 changed files with 1551 additions and 0 deletions
72
tests/integration/targets/connection_wsl/files/wsl.exe
Executable file
72
tests/integration/targets/connection_wsl/files/wsl.exe
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/usr/bin/env bash
|
||||
# Derived from ../../connection_proxmox_pct_remote/files/pct Copyright (c) 2025 Nils Stein (@mietzen) <github.nstein@mailbox.org>
|
||||
# Copyright (c) 2025 Rui Lopes (@rgl) <ruilopes.com>
|
||||
# Copyright (c) 2025 Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# Shell script to mock wsl.exe behavior
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
function quote_args {
|
||||
local quoted_args=()
|
||||
for arg in "$@"; do
|
||||
if [[ -z "$arg" || "$arg" =~ [^a-zA-Z0-9@%+=:,./-] ]]; then
|
||||
local escaped_arg=${arg//\'/\'\\\'\'}
|
||||
quoted_args+=("'$escaped_arg'")
|
||||
else
|
||||
quoted_args+=("$arg")
|
||||
fi
|
||||
done
|
||||
echo -n "${quoted_args[@]}"
|
||||
}
|
||||
|
||||
declare -a mock_args=()
|
||||
declare -a cmd_args=()
|
||||
wsl_distribution=""
|
||||
wsl_user=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--distribution|-d)
|
||||
wsl_distribution="$2"
|
||||
mock_args+=("$1" "$2")
|
||||
shift 2
|
||||
;;
|
||||
--user|-u)
|
||||
wsl_user="$2"
|
||||
mock_args+=("$1" "$2")
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
mock_args+=("$1")
|
||||
shift
|
||||
while [[ $# -gt 0 ]]; do
|
||||
mock_args+=("$1")
|
||||
cmd_args+=("$1")
|
||||
shift
|
||||
done
|
||||
;;
|
||||
*)
|
||||
>&2 echo "unexpected args: $@"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
mock_cmd="wsl.exe $(quote_args "${mock_args[@]}")"
|
||||
cmd="$(quote_args "${cmd_args[@]}")"
|
||||
|
||||
>&2 echo "[INFO] MOCKING: $mock_cmd"
|
||||
>&2 echo "[INFO] CMD: $cmd"
|
||||
|
||||
tmp_dir="/tmp/ansible-remote/wsl/integration_test/wsl_distribution_${wsl_distribution}"
|
||||
|
||||
mkdir -p "$tmp_dir"
|
||||
|
||||
pushd "$tmp_dir" >/dev/null
|
||||
|
||||
eval "$cmd"
|
||||
|
||||
popd >/dev/null
|
Loading…
Add table
Add a link
Reference in a new issue