2019-03-08 01:38:02 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eux
|
|
|
|
|
|
|
|
# We need to run these tests with both the powershell and cmd shell type
|
|
|
|
|
|
|
|
### cmd tests - no DefaultShell set ###
|
|
|
|
ansible -i ../../inventory.winrm localhost \
|
|
|
|
-m template \
|
2019-08-14 09:12:05 +02:00
|
|
|
-a "src=test_connection.inventory.j2 dest=${OUTPUT_DIR}/test_connection.inventory" \
|
2019-03-08 01:38:02 +01:00
|
|
|
-e "test_shell_type=cmd" \
|
|
|
|
"$@"
|
|
|
|
|
|
|
|
# https://github.com/PowerShell/Win32-OpenSSH/wiki/DefaultShell
|
|
|
|
ansible -i ../../inventory.winrm windows \
|
|
|
|
-m win_regedit \
|
|
|
|
-a "path=HKLM:\\\\SOFTWARE\\\\OpenSSH name=DefaultShell state=absent" \
|
|
|
|
"$@"
|
|
|
|
|
|
|
|
# Need to flush the connection to ensure we get a new shell for the next tests
|
2019-08-20 16:17:32 +02:00
|
|
|
ansible -i "${OUTPUT_DIR}/test_connection.inventory" windows \
|
2019-03-08 01:38:02 +01:00
|
|
|
-m meta -a "reset_connection" \
|
|
|
|
"$@"
|
|
|
|
|
|
|
|
# sftp
|
|
|
|
./windows.sh "$@"
|
|
|
|
# scp
|
2021-03-03 21:25:16 +01:00
|
|
|
ANSIBLE_SSH_TRANSFER_METHOD=scp ./windows.sh "$@"
|
2019-03-08 01:38:02 +01:00
|
|
|
# other tests not part of the generic connection test framework
|
2019-08-14 09:12:05 +02:00
|
|
|
ansible-playbook -i "${OUTPUT_DIR}/test_connection.inventory" tests.yml \
|
2019-03-08 01:38:02 +01:00
|
|
|
"$@"
|
|
|
|
|
|
|
|
### powershell tests - explicit DefaultShell set ###
|
|
|
|
# we do this last as the default shell on our CI instances is set to PowerShell
|
|
|
|
ansible -i ../../inventory.winrm localhost \
|
|
|
|
-m template \
|
2019-08-14 09:12:05 +02:00
|
|
|
-a "src=test_connection.inventory.j2 dest=${OUTPUT_DIR}/test_connection.inventory" \
|
2019-03-08 01:38:02 +01:00
|
|
|
-e "test_shell_type=powershell" \
|
|
|
|
"$@"
|
|
|
|
|
|
|
|
# ensure the default shell is set to PowerShell
|
|
|
|
ansible -i ../../inventory.winrm windows \
|
|
|
|
-m win_regedit \
|
|
|
|
-a "path=HKLM:\\\\SOFTWARE\\\\OpenSSH name=DefaultShell data=C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe" \
|
|
|
|
"$@"
|
|
|
|
|
2019-08-20 16:17:32 +02:00
|
|
|
ansible -i "${OUTPUT_DIR}/test_connection.inventory" windows \
|
2019-03-08 01:38:02 +01:00
|
|
|
-m meta -a "reset_connection" \
|
|
|
|
"$@"
|
|
|
|
|
|
|
|
./windows.sh "$@"
|
2021-03-03 21:25:16 +01:00
|
|
|
ANSIBLE_SSH_TRANSFER_METHOD=scp ./windows.sh "$@"
|
2019-08-14 09:12:05 +02:00
|
|
|
ansible-playbook -i "${OUTPUT_DIR}/test_connection.inventory" tests.yml \
|
2019-03-08 01:38:02 +01:00
|
|
|
"$@"
|