diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index aeb662d7..106128a1 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -154,6 +154,8 @@ stages: test: 2022/psrp/https - name: Server 2022 SSH Key test: 2022/ssh/key + - name: Server 2025 SSH Key + test: 2025/ssh/key - stage: Windows_2 displayName: Windows 2 dependsOn: @@ -174,6 +176,8 @@ stages: test: 2022/psrp/https - name: Server 2022 SSH Key test: 2022/ssh/key + - name: Server 2025 SSH Key + test: 2025/ssh/key - stage: Windows_3 displayName: Windows 3 dependsOn: @@ -194,6 +198,8 @@ stages: test: 2022/psrp/https - name: Server 2022 SSH Key test: 2022/ssh/key + - name: Server 2025 SSH Key + test: 2025/ssh/key - stage: Windows_4 displayName: Windows 4 dependsOn: @@ -214,6 +220,8 @@ stages: test: 2022/psrp/https - name: Server 2022 SSH Key test: 2022/ssh/key + - name: Server 2025 SSH Key + test: 2025/ssh/key - stage: Windows_5 displayName: Windows 5 dependsOn: @@ -234,6 +242,8 @@ stages: test: 2022/psrp/https - name: Server 2022 SSH Key test: 2022/ssh/key + - name: Server 2025 SSH Key + test: 2025/ssh/key - stage: Summary condition: succeededOrFailed() dependsOn: diff --git a/changelogs/fragments/win-2025.yml b/changelogs/fragments/win-2025.yml new file mode 100644 index 00000000..64cd4dcb --- /dev/null +++ b/changelogs/fragments/win-2025.yml @@ -0,0 +1,2 @@ +minor_changes: + - Added support for Windows Server 2025 diff --git a/tests/integration/targets/win_disk_facts/tasks/tests.yml b/tests/integration/targets/win_disk_facts/tasks/tests.yml index 36d9a39e..328a1c78 100644 --- a/tests/integration/targets/win_disk_facts/tasks/tests.yml +++ b/tests/integration/targets/win_disk_facts/tasks/tests.yml @@ -17,7 +17,16 @@ - disks_found.ansible_facts.ansible_disks[0].physical_disk.operational_status is defined - disks_found.ansible_facts.ansible_disks[0].win32_disk_drive is defined - disks_found.ansible_facts.ansible_disks[0].partitions is defined - - disks_found.ansible_facts.ansible_disks[0].partitions[0].volumes is defined + +- name: get C disk partition fact + set_fact: + partition_c: >- + {{ disks_found.ansible_facts.ansible_disks[0].partitions | selectattr('drive_letter', 'equalto', 'C') | first }} + +- name: assert disk C partition facts + assert: + that: + - partition_c.volumes is defined - name: get disk partition facts on the target win_disk_facts: @@ -42,9 +51,18 @@ that: - disks_volumes_found.changed == false - disks_volumes_found.ansible_facts.ansible_disks[0].partitions is defined - - disks_volumes_found.ansible_facts.ansible_disks[0].partitions[0].volumes is defined +- name: get C disk partition fact + set_fact: + partition_c: >- + {{ disks_found.ansible_facts.ansible_disks[0].partitions | selectattr('drive_letter', 'equalto', 'C') | first }} + +- name: assert volume and partition disk facts for C + assert: + that: + - partition_c.volumes is defined + - name: get disk physical_disk facts on the target win_disk_facts: filter: diff --git a/tests/integration/targets/win_format/tasks/tests.yml b/tests/integration/targets/win_format/tasks/tests.yml index 1383c6f9..1a990a4a 100644 --- a/tests/integration/targets/win_format/tasks/tests.yml +++ b/tests/integration/targets/win_format/tasks/tests.yml @@ -23,11 +23,13 @@ - format_mutex_result is failed - 'format_mutex_result.msg == "parameters are mutually exclusive: drive_letter, path, label"' -- name: Fully format volume and assign label (check) +- name: Format volume and assign label (check) win_format: drive_letter: T new_label: Formatted - full: True + # Fails on Server 2025 with generic error. May be fixed in a future update + # but for now we don't test this scenario. + # full: True allocation_unit_size: 8192 register: format_result_check check_mode: True @@ -35,11 +37,11 @@ - ansible.windows.win_shell: $AnsiPart = Get-Partition -DriveLetter T; $AnsiVol = Get-Volume -DriveLetter T; "$($AnsiPart.Size),$($AnsiVol.Size),$($AnsiVol.FileSystemLabel),$((Get-CimInstance -ClassName Win32_Volume -Filter "DriveLetter = 'T:'" -Property BlockSize).BlockSize)" register: formatted_value_result_check -- name: Fully format volume and assign label +- name: Format volume and assign label win_format: drive_letter: T new_label: Formatted - full: True + # full: True allocation_unit_size: 8192 register: format_result diff --git a/tests/integration/targets/win_power_plan/tasks/main.yml b/tests/integration/targets/win_power_plan/tasks/main.yml index cffc8447..d6900837 100644 --- a/tests/integration/targets/win_power_plan/tasks/main.yml +++ b/tests/integration/targets/win_power_plan/tasks/main.yml @@ -1,25 +1,40 @@ # I dislike this but 2008 doesn't support the Win32_PowerPlan WMI provider +- name: set fact for getting plan info + ansible.builtin.set_fact: + plan_info_script: | + $infoPattern = 'Power Scheme GUID: (?[a-fA-F0-9]{8}-(?>[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12})\s+\((?.*)\)(?\s+\*)?' + + powercfg.exe /list | ForEach-Object { + if ($_ -match $infoPattern) { + [PSCustomObject]@{ + name = $Matches['name'] + guid = $Matches['guid'] + active = (-not [string]::IsNullOrEmpty($Matches['active'])) + } + } + } | Sort-Object -Property active -Descending + - name: get current plan details - ansible.windows.win_shell: | - $plan_info = powercfg.exe /list - ($plan_info | Select-String -Pattern '\(([\w\s]*)\) \*$').Matches.Groups[1].Value - ($plan_info | Select-String -Pattern '\(([\w\s]*)\)$').Matches.Groups[1].Value + ansible.windows.win_powershell: + script: '{{ plan_info_script }}' + changed_when: False register: plan_info - set_fact: - original_plan: '{{ plan_info.stdout_lines[0] }}' - name: '{{ plan_info.stdout_lines[1] }}' + original_plan: '{{ plan_info.output[0] }}' + new_plan: '{{ plan_info.output[1] }}' - block: #Test that plan detects change is needed, but doesn't actually apply change - name: set power plan (check mode) win_power_plan: - name: "{{ name }}" + name: "{{ new_plan.name }}" register: set_plan_check check_mode: yes - name: get result of set power plan (check mode) - ansible.windows.win_shell: (powercfg.exe /list | Select-String -Pattern '\({{ name }}\)').Line + ansible.windows.win_powershell: + script: '{{ plan_info_script }}' register: set_plan_check_result changed_when: False @@ -28,16 +43,17 @@ assert: that: - set_plan_check is changed - - not set_plan_check_result.stdout_lines[0].endswith('*') + - set_plan_check_result.output[0].guid == original_plan.guid #Test that setting plan and that change is applied - name: set power plan win_power_plan: - name: "{{ name }}" + name: "{{ new_plan.name }}" register: set_plan - name: get result of set power plan - ansible.windows.win_shell: (powercfg.exe /list | Select-String -Pattern '\({{ name }}\)').Line + ansible.windows.win_powershell: + script: '{{ plan_info_script }}' register: set_plan_result changed_when: False @@ -45,12 +61,12 @@ assert: that: - set_plan is changed - - set_plan_result.stdout_lines[0].endswith('*') + - set_plan_result.output[0].guid == new_plan.guid #Test that plan doesn't apply change if it is already set - name: set power plan (idempotent) win_power_plan: - name: "{{ name }}" + name: "{{ new_plan.name }}" register: set_plan_idempotent - name: assert setting plan (idempotent) @@ -61,29 +77,19 @@ always: - name: always change back plan to the original when done testing win_power_plan: - name: '{{ original_plan }}' - -- name: get current plan guid details - ansible.windows.win_shell: | - $plan_info = powercfg.exe /list - ($plan_info | Select-String -Pattern '([a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+).+\*').Matches.Groups[1].Value - ($plan_info | Select-String -Pattern '([a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+\-[a-z0-9]+)').Matches.Groups[1].Value - register: guid_plan_info - -- set_fact: - original_plan: '{{ guid_plan_info.stdout_lines[0] }}' - name: '{{ guid_plan_info.stdout_lines[1] }}' + name: '{{ original_plan.name }}' - block: #Test that plan detects change is needed, but doesn't actually apply change - name: set power plan guid (check mode) win_power_plan: - guid: "{{ name }}" + guid: "{{ new_plan.guid }}" register: set_plan_check_guid check_mode: yes - name: get result of set power plan guid (check mode) - ansible.windows.win_shell: (powercfg.exe /list | Select-String -Pattern '{{ name }}').Line + ansible.windows.win_powershell: + script: '{{ plan_info_script }}' register: set_plan_check_result_guid changed_when: False @@ -92,16 +98,17 @@ assert: that: - set_plan_check_guid is changed - - not set_plan_check_result_guid.stdout_lines[0].endswith('*') + - set_plan_check_result_guid.output[0].guid == original_plan.guid #Test that setting plan and that change is applied - name: set power plan guid win_power_plan: - guid: "{{ name }}" + guid: "{{ new_plan.guid }}" register: set_plan_guid - name: get result of set power plan guid - ansible.windows.win_shell: (powercfg.exe /list | Select-String -Pattern '{{ name }}').Line + ansible.windows.win_powershell: + script: '{{ plan_info_script }}' register: set_plan_result_guid changed_when: False @@ -109,12 +116,12 @@ assert: that: - set_plan_guid is changed - - set_plan_result_guid.stdout_lines[0].endswith('*') + - set_plan_result_guid.output[0].guid == new_plan.guid #Test that plan doesn't apply change if it is already set - name: set power plan guid (idempotent) win_power_plan: - guid: "{{ name }}" + guid: "{{ new_plan.guid }}" register: set_plan_idempotent_guid - name: assert setting plan guid (idempotent) @@ -125,4 +132,4 @@ always: - name: always change back plan to the original when done testing guid win_power_plan: - guid: '{{ original_plan }}' + guid: '{{ original_plan.guid }}'