Debian Codegraph @

test/integration/targets/connection_windows_ssh/windows.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 cd ../connection
6
7 if [[ "$(scp -O 2>&1)" == "usage: scp "* ]]; then
8 # scp supports the -O option (and thus the -T option as well)
9 # work-around required
10 # see: https://www.openssh.com/txt/release-9.0
11 scp_args=("-e" "ansible_scp_extra_args=-TO")
12 elif [[ "$(scp -T 2>&1)" == "usage: scp "* ]]; then
13 # scp supports the -T option
14 # work-around required
15 # see: https://github.com/ansible/ansible/issues/52640
16 scp_args=("-e" "ansible_scp_extra_args=-T")
17 else
18 # scp does not support the -T or -O options
19 # no work-around required
20 # however we need to put something in the array to keep older versions of bash happy
21 scp_args=("-e" "")
22 fi
23
24 # A recent patch to OpenSSH causes a validation error when running through Ansible. It seems like if the path is quoted
25 # then it will fail with 'protocol error: filename does not match request'. We currently ignore this by setting
26 # 'ansible_scp_extra_args=-T' to ignore this check but this should be removed once that bug is fixed and our test
27 # container has been updated.
28 # https://unix.stackexchange.com/questions/499958/why-does-scps-strict-filename-checking-reject-quoted-last-component-but-not-oth
29 # https://github.com/openssh/openssh-portable/commit/391ffc4b9d31fa1f4ad566499fef9176ff8a07dc
30 INVENTORY="${OUTPUT_DIR}/test_connection.inventory" ./test.sh \
31 -e target_hosts=windows \
32 -e action_prefix=win_ \
33 -e local_tmp=/tmp/ansible-local \
34 -e remote_tmp=c:/windows/temp/ansible-remote \
35 "${scp_args[@]}" \
36 "$@"
37
38 cd ../connection_windows_ssh
39
40 ansible-playbook -i "${OUTPUT_DIR}/test_connection.inventory" tests_fetch.yml \
41 "${scp_args[@]}" \
42 "$@"