Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Windows Server 2025 #688

Merged
merged 2 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ stages:
test: 2022/psrp/https
- name: 2022 SSH Key
test: 2022/ssh/key
- name: 2025 PSRP HTTP
test: 2025/psrp/http
- name: 2025 SSH Key
test: 2025/ssh/key
- stage: Windows_2
displayName: Windows 2
dependsOn: []
Expand All @@ -146,6 +150,10 @@ stages:
test: 2022/psrp/https
- name: 2022 SSH Key
test: 2022/ssh/key
- name: 2025 PSRP HTTP
test: 2025/psrp/http
- name: 2025 SSH Key
test: 2025/ssh/key
- stage: Windows_3
displayName: Windows 3
dependsOn: []
Expand All @@ -165,6 +173,10 @@ stages:
test: 2022/psrp/https
- name: 2022 SSH Key
test: 2022/ssh/key
- name: 2025 PSRP HTTP
test: 2025/psrp/http
- name: 2025 SSH Key
test: 2025/ssh/key
- stage: Summary
condition: succeededOrFailed()
dependsOn:
Expand Down
2 changes: 2 additions & 0 deletions changelogs/fragments/win-2025.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Added support for Windows Server 2025
2 changes: 1 addition & 1 deletion tests/integration/targets/win_acl/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
test_acl_path: '{{ win_output_dir }}\win_acl .ÅÑŚÌβŁÈ [$!@^&test(;)]'
test_acl_path: '{{ remote_tmp_dir }}\win_acl .ÅÑŚÌβŁÈ [$!@^&test(;)]'
test_acl_network_path: \\localhost\{{ test_acl_path[0:1] }}$\{{ test_acl_path[3:] }}
# Use HKU as that path is not automatically loaded in the PSProvider making our test more complex
test_acl_reg_path: HKU:\.DEFAULT\Ansible Test .ÅÑŚÌβŁÈ [$!@^&test(;)]
2 changes: 2 additions & 0 deletions tests/integration/targets/win_acl/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- setup_remote_tmp_dir
12 changes: 2 additions & 10 deletions tests/integration/targets/win_acl/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
- name: ensure we start with a clean dir
- name: setup test directory
win_file:
path: '{{ test_acl_path }}'
state: '{{ item }}'
with_items:
- absent
- directory
state: directory

- name: ensure we start with a clean reg path
win_regedit:
Expand Down Expand Up @@ -54,11 +51,6 @@
include_tasks: tests.yml

always:
- name: cleanup testing dir
win_file:
path: '{{ test_acl_path }}'
state: absent

- name: cleanup testing reg path
win_regedit:
path: '{{ test_acl_reg_path }}'
Expand Down
37 changes: 37 additions & 0 deletions tests/integration/targets/win_package/library/prereq_setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!powershell

# Copyright: (c) 2024, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

#AnsibleRequires -CSharpUtil Ansible.Basic


$module = [Ansible.Basic.AnsibleModule]::Create($args, @{})

# Server 2025 fails to run Get-AppxPackage and other DISM module commands in
# a PSRemoting (psrp) session as it has a dependency on some dll's not present
# in the GAC and only in the powershell.exe directory. As PSRP runs through
# wsmprovhost.exe, it fails to find those dlls. This hack will manually load
# the 4 requires dlls into the GAC so our tests can work. This is a hack and
# should be removed in the future if MS fix their bug on 2025.
try {
$null = Get-AppxPackage
}
catch {
Add-Type -AssemblyName "System.EnterpriseServices"
$publish = [System.EnterpriseServices.Internal.Publish]::new()

@(
'System.Numerics.Vectors.dll',
'System.Runtime.CompilerServices.Unsafe.dll',
'System.Security.Principal.Windows.dll',
'System.Memory.dll'
) | ForEach-Object {
$dllPath = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\$_"
$publish.GacInstall($dllPath)
}

$module.Result.changed = $true
}

$module.ExitJson()
3 changes: 3 additions & 0 deletions tests/integration/targets/win_package/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
path: '{{ test_path }}'
state: directory

- name: setup 2025 pre-reqs for testing over PSRP
prereq_setup:

# Some of the registry_tests.yml create a badly formed unisntall string so remove the reg entry in case the test
# didn't get to cleaning itself up
- name: remove registry package path
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/targets/win_reboot/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- setup_remote_tmp_dir
4 changes: 2 additions & 2 deletions tests/integration/targets/win_reboot/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: make sure win output dir exists
win_file:
path: "{{win_output_dir}}"
path: "{{remote_tmp_dir}}"
state: directory

- name: reboot with defaults
Expand All @@ -21,7 +21,7 @@
# test a reboot that reboots again during the test_command phase
- name: create test file
win_file:
path: '{{win_output_dir}}\win_reboot_test'
path: '{{remote_tmp_dir}}\win_reboot_test'
state: touch

- name: reboot with secondary reboot stage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if (Test-Path -LiteralPath '{{win_output_dir}}\win_reboot_test') {
if (Test-Path -LiteralPath '{{remote_tmp_dir}}\win_reboot_test') {
New-ItemProperty -LiteralPath 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' `
-Name PendingFileRenameOperations `
-Value @("\??\{{win_output_dir}}\win_reboot_test`0") `
-Value @("\??\{{remote_tmp_dir}}\win_reboot_test`0") `
-PropertyType MultiString
Restart-Computer -Force
exit 1
Expand Down