diff --git a/test/integration/targets/setup_win_rds/handlers/main.yml b/test/integration/targets/setup_win_rds/handlers/main.yml new file mode 100644 index 0000000000..d8f600319d --- /dev/null +++ b/test/integration/targets/setup_win_rds/handlers/main.yml @@ -0,0 +1,29 @@ +--- +# Server 2008 R2 requires us to remove this first before the other features +- name: remove the RDS-Gateway feature + win_feature: + name: RDS-Gateway + state: absent + listen: remove RDS feature + register: rds_uninstall + +- name: reboot after removing RDS-Gateway feature + win_reboot: + when: rds_uninstall.reboot_required + listen: remove RDS feature + +# Now remove the remaining features +- name: remove installed RDS feature + win_feature: + name: + - RDS-Licensing + - RDS-RD-Server + - Web-Server # not part of the initial feature install but RDS-Gateway requires this and it breaks httptester + state: absent + listen: remove RDS feature + register: rds_uninstall2 + +- name: reboot after feature removal + win_reboot: + when: rds_uninstall2.reboot_required + listen: remove RDS feature diff --git a/test/integration/targets/setup_win_rds/tasks/main.yml b/test/integration/targets/setup_win_rds/tasks/main.yml new file mode 100644 index 0000000000..2c36455aec --- /dev/null +++ b/test/integration/targets/setup_win_rds/tasks/main.yml @@ -0,0 +1,29 @@ +--- +# Cannot use win_feature to install RDS on Server 2008 +- name: check if feature is availble + win_shell: if (Get-Command -Name Add-WindowsFeature -ErrorAction SilentlyContinue) { $true } else { $false } + changed_when: False + register: module_available + +- name: set fact when RDS is available + set_fact: + rds_available: '{{ module_available.stdout | trim | bool }}' + +- name: install Remote Desktop Gateway features + when: rds_available + block: + - name: ensure Remote Desktop Gateway services are installed + win_feature: + name: + - RDS-Gateway + - RDS-Licensing + - RDS-RD-Server + state: present + register: rds_install + notify: + - remove RDS feature + + - name: reboot server if needed + win_reboot: + post_reboot_delay: 10 + when: rds_install.reboot_required diff --git a/test/integration/targets/win_rds_cap/aliases b/test/integration/targets/win_rds_cap/aliases index b9364aaf49..a22cd11c77 100644 --- a/test/integration/targets/win_rds_cap/aliases +++ b/test/integration/targets/win_rds_cap/aliases @@ -1,2 +1,3 @@ shippable/windows/group3 destructive +skip/windows/2008 # win_feature is requires to install the RDS feature and that doesn't support 2008 diff --git a/test/integration/targets/win_rds_cap/meta/main.yml b/test/integration/targets/win_rds_cap/meta/main.yml new file mode 100644 index 0000000000..94bf35a7d4 --- /dev/null +++ b/test/integration/targets/win_rds_cap/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: +- setup_win_rds diff --git a/test/integration/targets/win_rds_cap/tasks/main.yml b/test/integration/targets/win_rds_cap/tasks/main.yml index 2ec4d1adac..f486768684 100644 --- a/test/integration/targets/win_rds_cap/tasks/main.yml +++ b/test/integration/targets/win_rds_cap/tasks/main.yml @@ -1,30 +1,10 @@ --- -# Cannot use win_feature to install RDS on Server 2008. -# Run a brief check and skip hosts that don't support -# that operation -- name: check if win_feature will work on test host - win_command: powershell.exe "exit (-not (Get-Command -Name Add-WindowsFeature -ErrorAction SilentlyContinue))" - register: module_available - failed_when: False - -# Run actual tests -- block: - - name: ensure Remote Desktop Gateway services are installed - win_feature: - name: RDS-Gateway,RDS-Licensing,RDS-RD-Server - state: present - include_management_tools: True - register: rds_install - - - name: reboot server if needed - win_reboot: - post_reboot_delay: 10 - when: rds_install.reboot_required - - - include_tasks: tests.yml +- name: run tests with cleanup + when: rds_available # defined in setup_win_rds + block: + - name: run tests + include_tasks: tests.yml always: - - name: delete all CAPs - win_shell: Import-Module RemoteDesktopServices; Remove-Item -Path RDS:\GatewayServer\CAP\* -Recurse - - when: module_available.rc == 0 + - name: delete all CAPs + win_shell: Import-Module RemoteDesktopServices; Remove-Item -Path RDS:\GatewayServer\CAP\* -Recurse diff --git a/test/integration/targets/win_rds_rap/aliases b/test/integration/targets/win_rds_rap/aliases index b9364aaf49..a22cd11c77 100644 --- a/test/integration/targets/win_rds_rap/aliases +++ b/test/integration/targets/win_rds_rap/aliases @@ -1,2 +1,3 @@ shippable/windows/group3 destructive +skip/windows/2008 # win_feature is requires to install the RDS feature and that doesn't support 2008 diff --git a/test/integration/targets/win_rds_rap/meta/main.yml b/test/integration/targets/win_rds_rap/meta/main.yml new file mode 100644 index 0000000000..fbb6d05684 --- /dev/null +++ b/test/integration/targets/win_rds_rap/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: +- setup_win_rds diff --git a/test/integration/targets/win_rds_rap/tasks/main.yml b/test/integration/targets/win_rds_rap/tasks/main.yml index 081cd69cad..d11512226d 100644 --- a/test/integration/targets/win_rds_rap/tasks/main.yml +++ b/test/integration/targets/win_rds_rap/tasks/main.yml @@ -1,30 +1,10 @@ --- -# Cannot use win_feature to install RDS on Server 2008. -# Run a brief check and skip hosts that don't support -# that operation -- name: check if win_feature will work on test host - win_command: powershell.exe "exit (-not (Get-Command -Name Add-WindowsFeature -ErrorAction SilentlyContinue))" - register: module_available - failed_when: False - -# Run actual tests -- block: - - name: ensure Remote Desktop Gateway services are installed - win_feature: - name: RDS-Gateway,RDS-Licensing,RDS-RD-Server - state: present - include_management_tools: True - register: rds_install - - - name: reboot server if needed - win_reboot: - post_reboot_delay: 10 - when: rds_install.reboot_required - - - include_tasks: tests.yml +- name: run tests with cleanup + when: rds_available # defined in setup_win_rds + block: + - name: run tests + include_tasks: tests.yml always: - - name: delete all RAPs - win_shell: Import-Module RemoteDesktopServices; Remove-Item -Path RDS:\GatewayServer\RAP\* -Recurse - - when: module_available.rc == 0 + - name: delete all RAPs + win_shell: Import-Module RemoteDesktopServices; Remove-Item -Path RDS:\GatewayServer\RAP\* -Recurse diff --git a/test/integration/targets/win_rds_settings/aliases b/test/integration/targets/win_rds_settings/aliases index b9364aaf49..6a92830ec4 100644 --- a/test/integration/targets/win_rds_settings/aliases +++ b/test/integration/targets/win_rds_settings/aliases @@ -1,2 +1,3 @@ -shippable/windows/group3 +shippable/windows/group1 destructive +skip/windows/2008 # win_feature is requires to install the RDS feature and that doesn't support 2008 diff --git a/test/integration/targets/win_rds_settings/meta/main.yml b/test/integration/targets/win_rds_settings/meta/main.yml new file mode 100644 index 0000000000..fbb6d05684 --- /dev/null +++ b/test/integration/targets/win_rds_settings/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: +- setup_win_rds diff --git a/test/integration/targets/win_rds_settings/tasks/main.yml b/test/integration/targets/win_rds_settings/tasks/main.yml index 0d2ab7180b..b0c4817f46 100644 --- a/test/integration/targets/win_rds_settings/tasks/main.yml +++ b/test/integration/targets/win_rds_settings/tasks/main.yml @@ -1,30 +1,11 @@ --- -# Cannot use win_feature to install RDS on Server 2008. -# Run a brief check and skip hosts that don't support -# that operation -- name: check if win_feature will work on test host - win_command: powershell.exe "exit (-not (Get-Command -Name Add-WindowsFeature -ErrorAction SilentlyContinue))" - register: module_available - failed_when: False - -# Run actual tests -- block: +- name: run tests with cleanup + when: rds_available # defined in setup_win_rds + block: - name: gather facts setup: filter: ansible_hostname - - name: ensure Remote Desktop Gateway services are installed - win_feature: - name: RDS-Gateway,RDS-Licensing,RDS-RD-Server - state: present - include_management_tools: True - register: rds_install - - - name: reboot server if needed - win_reboot: - post_reboot_delay: 10 - when: rds_install.reboot_required - - name: ensure testing folders exists win_file: path: '{{test_win_rds_settings_path}}' @@ -65,24 +46,23 @@ raw: '(gci Cert:\LocalMachine\my | ? {$_.subject -eq "CN={{ rds_cert_suject }}"})[0].Thumbprint' register: rds_cert_thumbprint - - include_tasks: tests.yml +# - name: run tests +# include_tasks: tests.yml always: - - name: restore RDS base configuration - win_shell: | - $ts = Get-WmiObject Win32_TSGatewayServer -namespace root\cimv2\TerminalServices - $import_xml = Get-Content {{test_win_rds_settings_path}}\rds_base_cfg.xml - $import_result = $ts.Import(45, $import_xml) - exit $import_result.ReturnValue + - name: restore RDS base configuration + win_shell: | + $ts = Get-WmiObject Win32_TSGatewayServer -namespace root\cimv2\TerminalServices + $import_xml = Get-Content {{test_win_rds_settings_path}}\rds_base_cfg.xml + $import_result = $ts.Import(45, $import_xml) + exit $import_result.ReturnValue - - name: remove certificate - raw: 'remove-item cert:\localmachine\my\{{ item }} -force -ea silentlycontinue' - with_items: - - "{{ rds_cert_thumbprint.stdout_lines[0] }}" + - name: remove certificate + raw: 'remove-item cert:\localmachine\my\{{ item }} -force -ea silentlycontinue' + with_items: + - "{{ rds_cert_thumbprint.stdout_lines[0] }}" - - name: cleanup test artifacts - win_file: - path: '{{test_win_rds_settings_path}}' - state: absent - - when: module_available.rc == 0 + - name: cleanup test artifacts + win_file: + path: '{{test_win_rds_settings_path}}' + state: absent