Debian Codegraph @

test/integration/targets/connection_windows_ssh/runme.sh

raw
1 #!/usr/bin/env bash
2
3 set -eux
4
5 # We need to run these tests with both the powershell and cmd shell type
6
7 ### cmd tests - no DefaultShell set ###
8 ansible -i ../../inventory.winrm localhost \
9 -m template \
10 -a "src=test_connection.inventory.j2 dest=${OUTPUT_DIR}/test_connection.inventory" \
11 -e "test_shell_type=cmd" \
12 "$@"
13
14 # https://github.com/PowerShell/Win32-OpenSSH/wiki/DefaultShell
15 ansible -i ../../inventory.winrm windows \
16 -m win_regedit \
17 -a "path=HKLM:\\\\SOFTWARE\\\\OpenSSH name=DefaultShell state=absent" \
18 "$@"
19
20 # Need to flush the connection to ensure we get a new shell for the next tests
21 ansible -i "${OUTPUT_DIR}/test_connection.inventory" windows \
22 -m meta -a "reset_connection" \
23 "$@"
24
25 # sftp
26 ./windows.sh "$@"
27 # scp
28 ANSIBLE_SSH_TRANSFER_METHOD=scp ./windows.sh "$@"
29 # other tests not part of the generic connection test framework
30 ansible-playbook -i "${OUTPUT_DIR}/test_connection.inventory" tests.yml \
31 "$@"
32
33 ### powershell tests - explicit DefaultShell set ###
34 # we do this last as the default shell on our CI instances is set to PowerShell
35 ansible -i ../../inventory.winrm localhost \
36 -m template \
37 -a "src=test_connection.inventory.j2 dest=${OUTPUT_DIR}/test_connection.inventory" \
38 -e "test_shell_type=powershell" \
39 "$@"
40
41 # ensure the default shell is set to PowerShell - use an explicit shell
42 # var as a previous task set the default shell to cmd and we don't want to
43 # inherit the ansible-test defaults in inventory.winrm.
44 ansible -i ../../inventory.winrm windows \
45 -m win_regedit \
46 -a "path=HKLM:\\\\SOFTWARE\\\\OpenSSH name=DefaultShell data=C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe" \
47 -e "ansible_shell_type=cmd" \
48 "$@"
49
50 ansible -i "${OUTPUT_DIR}/test_connection.inventory" windows \
51 -m meta -a "reset_connection" \
52 "$@"
53
54 ./windows.sh "$@"
55 ANSIBLE_SSH_TRANSFER_METHOD=scp ./windows.sh "$@"
56 ansible-playbook -i "${OUTPUT_DIR}/test_connection.inventory" tests.yml \
57 "$@"