From cdf5a2fda29cfc8e01e2b1581d1b8211545db508 Mon Sep 17 00:00:00 2001 From: dw035535 Date: Tue, 21 Jan 2025 07:45:12 +0000 Subject: [PATCH 1/8] add guest info Signed-off-by: dw035535 --- .../check_os_fullname/win_guest_os_info.yml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 windows/check_os_fullname/win_guest_os_info.yml diff --git a/windows/check_os_fullname/win_guest_os_info.yml b/windows/check_os_fullname/win_guest_os_info.yml new file mode 100644 index 000000000..dcdb7e8e6 --- /dev/null +++ b/windows/check_os_fullname/win_guest_os_info.yml @@ -0,0 +1,62 @@ +# Copyright 2024 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause +--- +- name: "Set fact of the dict of the Windows guest OS info" + ansible.builtin.set_fact: + win_gos_info: [ + 'Windows 10 32bit': { + 'win_guest_id': 'windows9Guest', + 'win_guest_vmtools': '10.0.0', + 'win_guest_creation_esxi': 'NA', + 'win_guest_fullname': 'Microsoft Windows 10 (32-bit)' + }, + 'Windows 10 64bit': { + 'win_guest_id': 'windows9_64Guest', + 'win_guest_vmtools': '10.0.0', + 'win_guest_creation_esxi': 'NA', + 'win_guest_fullname': 'Microsoft Windows 10 (64-bit)' + }, + 'Windows 11': { + 'win_guest_id': 'windows11_64Guest', + 'win_guest_vmtools': '12.0.0', + 'win_guest_creation_esxi': 'NA', + 'win_guest_fullname': 'Microsoft Windows 11 (64-bit)' + }, + 'Windows next': { + 'win_guest_id': 'NA', + 'win_guest_vmtools': 'NA', + 'win_guest_creation_esxi': 'NA', + 'win_guest_fullname': 'NA' + }, + 'Windows Server 2016': { + 'win_guest_id': 'windows9Server64Guest', + 'win_guest_vmtools': '10.0.0', + 'win_guest_creation_esxi': 'NA', + 'win_guest_fullname': 'Microsoft Windows Server 2016 (64-bit)' + }, + 'Windows Server 2019': { + 'win_guest_id': 'windows2019srv_64Guest', + 'win_guest_vmtools': 'NA', + 'win_guest_creation_esxi': '7.0.0', + 'win_guest_fullname': 'Microsoft Windows Server 2019 (64-bit)' + }, + 'Windows Server 2022': { + 'win_guest_id': 'Windows2019srvNext_64Guest', + 'win_guest_vmtools': '11.3.0', + 'win_guest_creation_esxi': '', + 'win_guest_fullname': 'Microsoft Windows Server 2022 (64-bit)' + }, + 'Windows Server 2025': { + 'win_guest_id': 'Windows2022srvNext_64Guest', + 'win_guest_vmtools': '12.0.5', + 'win_guest_add_esxi': '8.0.0', + 'win_guest_creation_esxi': '8.0.3', + 'win_guest_fullname': 'Microsoft Windows Server 2025 (64-bit)' + }, + 'Windows Server next': { + 'win_guest_id': 'NA', + 'win_guest_vmtools': 'NA', + 'win_guest_creation_esxi': 'NA', + 'win_guest_fullname': 'NA' + } + ] From 6465f514af32b93460eed2c1d2b348e7c1c7e273 Mon Sep 17 00:00:00 2001 From: dw035535 Date: Fri, 7 Feb 2025 05:04:43 +0000 Subject: [PATCH 2/8] change the logic of checking guest fullname Signed-off-by: dw035535 --- .../check_os_fullname/check_os_fullname_2.yml | 16 ++++++++++++++++ windows/check_os_fullname/win_guest_os_info.yml | 12 ++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 windows/check_os_fullname/check_os_fullname_2.yml diff --git a/windows/check_os_fullname/check_os_fullname_2.yml b/windows/check_os_fullname/check_os_fullname_2.yml new file mode 100644 index 000000000..61b39d77d --- /dev/null +++ b/windows/check_os_fullname/check_os_fullname_2.yml @@ -0,0 +1,16 @@ +# ESXi version >= win_guest_add_esxi (or win_guest_creation_esxi) +# 1. Installed VMware Tools >= win_guest_vmtools +# > expected guest info + +# 2. Installed VMware Tools < win_guest_vmtools +# > configured guest ID should be the expected guest ID +# > guest ID corresponding guest info + +# ESXi version < win_guest_add_esxi (or win_guest_creation_esxi) +# 1. Installed VMware Tools >= win_guest_vmtools +# > configured guest ID should be the previous guest ID +# > guest ID corresponding guest info + +# 2. Installed VMware Tools < win_guest_vmtools +# > configured guest ID should be the previous guest ID +# > guest ID corresponding guest info diff --git a/windows/check_os_fullname/win_guest_os_info.yml b/windows/check_os_fullname/win_guest_os_info.yml index dcdb7e8e6..f91c2c48f 100644 --- a/windows/check_os_fullname/win_guest_os_info.yml +++ b/windows/check_os_fullname/win_guest_os_info.yml @@ -7,19 +7,19 @@ 'Windows 10 32bit': { 'win_guest_id': 'windows9Guest', 'win_guest_vmtools': '10.0.0', - 'win_guest_creation_esxi': 'NA', + 'win_guest_creation_esxi': '5.5.3', 'win_guest_fullname': 'Microsoft Windows 10 (32-bit)' }, 'Windows 10 64bit': { 'win_guest_id': 'windows9_64Guest', 'win_guest_vmtools': '10.0.0', - 'win_guest_creation_esxi': 'NA', + 'win_guest_creation_esxi': '5.5.3', 'win_guest_fullname': 'Microsoft Windows 10 (64-bit)' }, 'Windows 11': { 'win_guest_id': 'windows11_64Guest', 'win_guest_vmtools': '12.0.0', - 'win_guest_creation_esxi': 'NA', + 'win_guest_creation_esxi': '8.0.0', 'win_guest_fullname': 'Microsoft Windows 11 (64-bit)' }, 'Windows next': { @@ -31,19 +31,19 @@ 'Windows Server 2016': { 'win_guest_id': 'windows9Server64Guest', 'win_guest_vmtools': '10.0.0', - 'win_guest_creation_esxi': 'NA', + 'win_guest_creation_esxi': '5.5.3', 'win_guest_fullname': 'Microsoft Windows Server 2016 (64-bit)' }, 'Windows Server 2019': { 'win_guest_id': 'windows2019srv_64Guest', - 'win_guest_vmtools': 'NA', + 'win_guest_vmtools': '11.0.5', 'win_guest_creation_esxi': '7.0.0', 'win_guest_fullname': 'Microsoft Windows Server 2019 (64-bit)' }, 'Windows Server 2022': { 'win_guest_id': 'Windows2019srvNext_64Guest', 'win_guest_vmtools': '11.3.0', - 'win_guest_creation_esxi': '', + 'win_guest_creation_esxi': '7.0.1', 'win_guest_fullname': 'Microsoft Windows Server 2022 (64-bit)' }, 'Windows Server 2025': { From aeb31241b84a3d94438c0563e22990b3e8ecb7e8 Mon Sep 17 00:00:00 2001 From: dw035535 Date: Mon, 10 Feb 2025 08:23:12 +0000 Subject: [PATCH 3/8] add get previous gos info Signed-off-by: dw035535 --- .../check_os_fullname/check_os_fullname.yml | 66 +++++++------------ .../get_previous_gos_info.yml | 50 ++++++++++++++ .../check_os_fullname/win_guest_os_info.yml | 62 ++++++++--------- 3 files changed, 106 insertions(+), 72 deletions(-) create mode 100644 windows/check_os_fullname/get_previous_gos_info.yml diff --git a/windows/check_os_fullname/check_os_fullname.yml b/windows/check_os_fullname/check_os_fullname.yml index 4e3949436..8a611a824 100644 --- a/windows/check_os_fullname/check_os_fullname.yml +++ b/windows/check_os_fullname/check_os_fullname.yml @@ -10,27 +10,31 @@ hosts: localhost gather_facts: false tasks: - - block: - - include_tasks: ../setup/test_setup.yml + - name: "Test case block" + block: + - name: "Test setup" + include_tasks: ../setup/test_setup.yml vars: skip_test_no_vmtools: true - # Get OS info inside guest OS - - include_tasks: ../utils/win_get_fullname.yml - - ansible.builtin.debug: + - name: "Get OS info inside guest OS" + include_tasks: ../utils/win_get_fullname.yml + + - name: "Print OS info" + ansible.builtin.debug: msg: - "Get guest fullname in guest OS: {{ os_fullname_guest }}" - "Get OS architecture in guest OS: {{ guest_os_ansible_architecture }}" - "VM guest ID is: {{ vm_guest_id }}" - # Get ESXi version info if not defined - - include_tasks: ../../common/esxi_get_version_build.yml + - name: "Get ESXi version info if not defined" + include_tasks: ../../common/esxi_get_version_build.yml when: > (esxi_version is undefined) or (esxi_version == 'N/A') - # Get guest fullname from VM guest info - - include_tasks: ../../common/vm_get_guest_info.yml + - name: "Get guest fullname from VM guest info" + include_tasks: ../../common/vm_get_guest_info.yml - name: "Known issue - ignore incorrect guestID of Windows 11" ansible.builtin.debug: @@ -48,6 +52,7 @@ - "'Windows 11' in os_fullname_guest" - vmtools_version is defined and vmtools_version - vmtools_version is version('12.0.0', '>=') + - name: "Check guest ID got from guest info is not empty" ansible.builtin.assert: that: @@ -60,39 +65,16 @@ (esxi_version is version('7.0.3', '=') and (esxi_build is undefined or esxi_build != "19193900")) or (vmtools_version is undefined or vmtools_version is version('12.0.0', '<')) - - name: Initialize the expected guest fullname - ansible.builtin.set_fact: - expected_guest_fullname: "" - # Set expected guest fullname for Windows client - - block: - - include_tasks: win10_fullname.yml - when: "'Windows 10' in os_fullname_guest" - - include_tasks: win11_fullname.yml - when: "'Windows 11' in os_fullname_guest" - when: guest_os_product_type == "client" - - # Set expected guest fullname for Windows Server - - block: - - block: - - include_tasks: winsrv2016orlater_fullname.yml - - include_tasks: winsrv2019_fullname.yml - when: not "'Windows Server 2022' in os_fullname_guest" - - include_tasks: winsrv2022_fullname.yml - when: - - "'Windows Server 2022' in os_fullname_guest" - - guest_os_build_num | int == 20348 - - include_tasks: winsrvnext_fullname.yml - when: - - guest_os_build_num | int >= 22424 - when: guest_os_product_type != "client" - - - ansible.builtin.debug: - msg: "Expected guest fullname on ESXi '{{ esxi_version }}': {{ expected_guest_fullname }}" - - name: "Verify guest fullname in guest info is expected" + - name: "Set fact of the guest OS info list" + include_tasks: win_guest_os_info.yml + + - name: "Check current guest OS in the guest OS info list" ansible.builtin.assert: that: - - expected_guest_fullname != "" - - (guestinfo_guest_full_name == expected_guest_fullname) or (expected_guest_fullname is string and expected_guest_fullname in guestinfo_guest_full_name) or (expected_guest_fullname | type_debug == 'list' and guestinfo_guest_full_name in expected_guest_fullname) - fail_msg: "Guest fullname in guest info: {{ guestinfo_guest_full_name }}, is not the same as expected one: {{ expected_guest_fullname }}." + - win_gos_info | selectattr('win_guest', 'equalto', current_gos) + fail_msg: + - "The defined Windows guest OS info list does not contain this OS version: {{ current_gos }}," + - "please check if this guest OS is supported and add it's info to the list accordingly." rescue: - - include_tasks: ../../common/test_rescue.yml + - name: "Test case failure" + include_tasks: ../../common/test_rescue.yml diff --git a/windows/check_os_fullname/get_previous_gos_info.yml b/windows/check_os_fullname/get_previous_gos_info.yml new file mode 100644 index 000000000..2c50c585b --- /dev/null +++ b/windows/check_os_fullname/get_previous_gos_info.yml @@ -0,0 +1,50 @@ +# Copyright 2025 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause +--- +# Get the previous guest OS info in the pre-defined 'win_gos_info' +# before the current guest OS version +- name: "Check current guest OS in the guest OS info list" + ansible.builtin.assert: + that: + - win_gos_info | selectattr('win_guest', 'equalto', current_gos) + fail_msg: + - "The defined Windows guest OS info list does not contain this OS version: {{ current_gos }}," + - "please check if this guest OS is supported and add it's info to the list accordingly." + +- name: "Initialize the previous guest OS info" + ansible.builtin.set_fact: + previous_gos: "" + +- name: "Set fact of the Windows Server guest OS info" + ansible.builtin.set_fact: + gos_list: "{{ win_gos_info | selectattr('win_guest', 'search', 'Server') }}" + +- name: "Set fact of the Windows Client guest OS info" + ansible.builtin.set_fact: + gos_list: "{{ win_gos_info | difference(gos_list) }}" + when: guest_os_product_type == "client" + +- name: "Sort the guest OS info list" + ansible.builtin.set_fact: + gos_list: "{{ gos_list | sort(attribute='win_guest', reverse=true) }}" + +- debug: var=gos_list + +- name: "Set fact of the index of current guest OS in the list" + ansible.builtin.set_fact: + current_gos_index: "{{ (gos_list | map(attribute='win_guest') | list).index(current_gos) }}" + +- debug: var=current_gos_index + +- name: "No previous guest OS in the list" + ansible.builtin.debug: + msg: "Current guest OS '{{ current_gos }}' has no previous earlier version in the defeined guest OS info list." + when: current_gos_index | int == gos_list | length - 1 + +- name: "Set fact of the previous guest OS" + ansible.builtin.set_fact: + previous_gos: "{{ gos_list[current_gos_index | int + 1] }}" + when: current_gos_index | int < gos_list | length - 1 + +- name: "Print the previous guest OS info" + ansible.builtin.debug: var=previous_gos diff --git a/windows/check_os_fullname/win_guest_os_info.yml b/windows/check_os_fullname/win_guest_os_info.yml index f91c2c48f..17cbf6b22 100644 --- a/windows/check_os_fullname/win_guest_os_info.yml +++ b/windows/check_os_fullname/win_guest_os_info.yml @@ -4,59 +4,61 @@ - name: "Set fact of the dict of the Windows guest OS info" ansible.builtin.set_fact: win_gos_info: [ - 'Windows 10 32bit': { - 'win_guest_id': 'windows9Guest', + { + 'win_guest': 'Windows 10', + 'win_guest_id': ['windows9Guest', 'windows9_64Guest'], 'win_guest_vmtools': '10.0.0', 'win_guest_creation_esxi': '5.5.3', - 'win_guest_fullname': 'Microsoft Windows 10 (32-bit)' + 'win_guest_fullname': ["{{ 'Microsoft Windows 10 (' ~ guest_os_ansible_architecture ~ ')' }}"] }, - 'Windows 10 64bit': { - 'win_guest_id': 'windows9_64Guest', - 'win_guest_vmtools': '10.0.0', - 'win_guest_creation_esxi': '5.5.3', - 'win_guest_fullname': 'Microsoft Windows 10 (64-bit)' - }, - 'Windows 11': { - 'win_guest_id': 'windows11_64Guest', + { + 'win_guest': 'Windows 11', + 'win_guest_id': ['windows11_64Guest'], 'win_guest_vmtools': '12.0.0', 'win_guest_creation_esxi': '8.0.0', - 'win_guest_fullname': 'Microsoft Windows 11 (64-bit)' + 'win_guest_fullname': ['Microsoft Windows 11 (64-bit)'] }, - 'Windows next': { - 'win_guest_id': 'NA', + { + 'win_guest': 'Windows next', + 'win_guest_id': [], 'win_guest_vmtools': 'NA', 'win_guest_creation_esxi': 'NA', - 'win_guest_fullname': 'NA' + 'win_guest_fullname': '[]' }, - 'Windows Server 2016': { - 'win_guest_id': 'windows9Server64Guest', + { + 'win_guest': 'Windows Server 2016', + 'win_guest_id': ['windows9Server64Guest'], 'win_guest_vmtools': '10.0.0', 'win_guest_creation_esxi': '5.5.3', - 'win_guest_fullname': 'Microsoft Windows Server 2016 (64-bit)' + 'win_guest_fullname': ['Microsoft Windows Server 2016 (64-bit)', 'Microsoft Windows Server 2016 or later (64-bit)'] }, - 'Windows Server 2019': { - 'win_guest_id': 'windows2019srv_64Guest', + { + 'win_guest': 'Windows Server 2019', + 'win_guest_id': ['windows2019srv_64Guest'], 'win_guest_vmtools': '11.0.5', 'win_guest_creation_esxi': '7.0.0', - 'win_guest_fullname': 'Microsoft Windows Server 2019 (64-bit)' + 'win_guest_fullname': ['Microsoft Windows Server 2019 (64-bit)'] }, - 'Windows Server 2022': { - 'win_guest_id': 'Windows2019srvNext_64Guest', + { + 'win_guest': 'Windows Server 2022', + 'win_guest_id': ['Windows2019srvNext_64Guest'], 'win_guest_vmtools': '11.3.0', 'win_guest_creation_esxi': '7.0.1', - 'win_guest_fullname': 'Microsoft Windows Server 2022 (64-bit)' + 'win_guest_fullname': ['Microsoft Windows Server 2021 (64-bit)', 'Microsoft Windows Server 2022 (64-bit)'] }, - 'Windows Server 2025': { - 'win_guest_id': 'Windows2022srvNext_64Guest', + { + 'win_guest': 'Windows Server 2025', + 'win_guest_id': ['Windows2022srvNext_64Guest'], 'win_guest_vmtools': '12.0.5', 'win_guest_add_esxi': '8.0.0', 'win_guest_creation_esxi': '8.0.3', - 'win_guest_fullname': 'Microsoft Windows Server 2025 (64-bit)' + 'win_guest_fullname': ['Microsoft Windows Server 2025 (64-bit)'] }, - 'Windows Server next': { - 'win_guest_id': 'NA', + { + 'win_guest': 'Windows Server next', + 'win_guest_id': [], 'win_guest_vmtools': 'NA', 'win_guest_creation_esxi': 'NA', - 'win_guest_fullname': 'NA' + 'win_guest_fullname': [] } ] From 12a3ca7d7a2d5a247d2d8a1aadab434a50d580e2 Mon Sep 17 00:00:00 2001 From: dw035535 Date: Tue, 11 Feb 2025 08:25:31 +0000 Subject: [PATCH 4/8] change guest fullname check Signed-off-by: dw035535 --- .../get_inbox_driver_info.yml | 2 +- .../check_guest_fullname_guest_info.yml | 61 ++++++++++++++ .../check_guest_id_guest_info.yml | 24 ++++++ .../check_os_fullname/check_os_fullname.yml | 83 +++++++------------ .../get_previous_gos_info.yml | 14 +--- .../check_os_fullname/win_guest_os_info.yml | 16 +++- .../check_after_gos_upgrade.yml | 2 +- windows/utils/get_windows_system_info.yml | 5 ++ 8 files changed, 138 insertions(+), 69 deletions(-) create mode 100644 windows/check_os_fullname/check_guest_fullname_guest_info.yml create mode 100644 windows/check_os_fullname/check_guest_id_guest_info.yml diff --git a/windows/check_inbox_driver/get_inbox_driver_info.yml b/windows/check_inbox_driver/get_inbox_driver_info.yml index 5edf7c0bb..82ac398d1 100644 --- a/windows/check_inbox_driver/get_inbox_driver_info.yml +++ b/windows/check_inbox_driver/get_inbox_driver_info.yml @@ -45,7 +45,7 @@ block: - name: "Set fact of the file path for recording inbox drivers info" ansible.builtin.set_fact: - drivers_info_file_path: "{{ current_test_log_folder }}/{{ ('-').join(guest_os_ansible_distribution.split(' ')[1:-1]) }}-{{ guest_os_build_num }}-{{ guest_os_ansible_architecture.replace('-', '') }}.json" + drivers_info_file_path: "{{ current_test_log_folder }}/{{ ('-').join(guest_os_ansible_distribution.split(' ')[1:]) }}-{{ guest_os_build_num }}-{{ guest_os_ansible_architecture.replace('-', '') }}.json" - name: "Dump inbox drivers info to json file" ansible.builtin.copy: dest: "{{ drivers_info_file_path }}" diff --git a/windows/check_os_fullname/check_guest_fullname_guest_info.yml b/windows/check_os_fullname/check_guest_fullname_guest_info.yml new file mode 100644 index 000000000..805ebb0e2 --- /dev/null +++ b/windows/check_os_fullname/check_guest_fullname_guest_info.yml @@ -0,0 +1,61 @@ +# Copyright 2025 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause +--- +# Get supported for create guest IDs +- name: "Get supported guest IDs on ESXi {{ esxi_version }} with hardware version {{ vm_hardware_version_num }}" + include_tasks: ../../common/esxi_get_guest_ids.yml + vars: + esxi_hardware_version: "{{ vm_hardware_version_num }}" + +# Set expected guest ID corresponding to current OS +- name: "Set fact of expected guest ID of current {{ guest_os_ansible_architecture }} OS" + ansible.builtin.set_fact: + current_os_guest_id: "{{ (guest_os_ansible_architecture == '64-bit' | ternary(current_gos_info['win_guest_id'] | select('match', '.*64Guest'), current_gos_info['win_guest_id'] | reject('match', '.*64Guest')))[0] }}" + +# Expected guest ID in supported guest IDs list +- name: "Check guest ID and fullname in VM guest info" + ansible.builtin.assert: + that: + - guestinfo_guest_id == vm_guest_id + - guestinfo_guest_id == current_os_guest_id + - guestinfo_guest_full_name in current_gos_info['win_guest_fullname'] + fail_msg: + - "Guest ID in VM guest info '{{ guestinfo_guest_id }}' should be equal to the configured guest ID '{{ vm_guest_id }}'," + - "Guest ID in VM guest info '{{ guestinfo_guest_id }}' should be equal to the expected one '{{ current_os_guest_id }}'," + - "Guest fullname in VM guest info '{{ guestinfo_guest_full_name }}' should be in the expected list '{{ current_gos_info['win_guest_fullname'] }}'." + when: current_os_guest_id in esxi_guest_ids + +# Expected guest ID not in supported guest IDs list +- name: "Guest ID is not supported for create on ESXi {{ esxi_version }}" + when: current_os_guest_id not in esxi_guest_ids + block: + - name: "Get the previous OS info in the pre-defined guest OS info list" + include_tasks: get_previous_gos_info.yml + + # Set expected guest ID corresponding to previous OS version + - name: "Set fact of expected guest ID of previous {{ guest_os_ansible_architecture }} OS" + ansible.builtin.set_fact: + previous_os_guest_id: "{{ (guest_os_ansible_architecture == '64-bit' | ternary(previous_gos_info['win_guest_id'] | select('match', '.*64Guest'), previous_gos_info['win_guest_id'] | reject('match', '.*64Guest')))[0] }}" + + - name: "Check VM configured guest ID is the previous guest ID" + ansible.builtin.assert: + that: + - vm_guest_id == previous_os_guest_id + fail_msg: + - "VM guest ID '{{ vm_guest_id }}' is not configured to the one of the previous OS version: {{ previous_os_guest_id }}," + - "since guest ID '{{ current_os_guest_id }}' of current OS is not found in the supported for create guest IDs on ESXi." + +# Guest ID is defined while not supported for create +- name: "Set fact of the conditions guest OS is recognized" + ansible.builtin.set_fact: + current_os_recognized: true + configured_pre_guest_id: true + when: + - current_gos_info.win_guest_add_esxi is defined and current_gos_info.win_guest_add_esxi + - esxi_version is version(current_gos_info.win_guest_add_esxi, '>=') + - esxi_version is version(current_gos_info.win_guest_creation_esxi, '<') + - vmtools_version is version(current_gos_info.win_guest_vmtools, '>=') + +# Current ESXi version does not contain the current OS defination +# 1. Current VMware Tools version can recognize the current OS +# 2. Current VMware Tools version can not recognize the current OS diff --git a/windows/check_os_fullname/check_guest_id_guest_info.yml b/windows/check_os_fullname/check_guest_id_guest_info.yml new file mode 100644 index 000000000..6c7c8359f --- /dev/null +++ b/windows/check_os_fullname/check_guest_id_guest_info.yml @@ -0,0 +1,24 @@ +# Copyright 2025 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause +--- +- name: "Set fact of the condidtions of the known issue on Windows 11" + ansible.builtin.set_fact: + win11_known_issue: "{{ os_fullname_guest is search('Windows 11') and esxi_version is version('7.0.3', '=') and esxi_build == '19193900' and vmtools_version is version('12.0.0', '>=') }}" + +- name: "Known issue - incorrect/empty guestID in guest info of Windows 11" + ansible.builtin.debug: + msg: + - "The guestID of Windows 11 guest in guestinfo is empty on ESXi 7.0U3c. Ignore this known issue." + - "Please refer to https://knowledge.broadcom.com/external/article?legacyId=86517." + tags: + - known_issue + when: + - win11_known_issue + - not guestinfo_guest_id + +- name: "Check guest ID got from guest info is not empty" + ansible.builtin.assert: + that: + - guestinfo_guest_id + fail_msg: "Guest ID in guest info is '{{ guestinfo_guest_id }}', which should be a valid value firstly." + when: not win11_known_issue diff --git a/windows/check_os_fullname/check_os_fullname.yml b/windows/check_os_fullname/check_os_fullname.yml index 8a611a824..c73b893ab 100644 --- a/windows/check_os_fullname/check_os_fullname.yml +++ b/windows/check_os_fullname/check_os_fullname.yml @@ -2,9 +2,10 @@ # SPDX-License-Identifier: BSD-2-Clause --- # Description: -# This test case is used for check VM guest OS fullname is reported correctly -# in guest info through VMware Tools. When VMware Tools is not installed or not -# running in VM, this test case result is 'No Run'. +# This test case is used for check VM guest fullname and guest ID +# are reported correctly in the VM guest info through VMware Tools. +# When VMware Tools is not installed or not running in VM, +# this test case result is 'Blocked'. # - name: check_os_fullname hosts: localhost @@ -17,64 +18,40 @@ vars: skip_test_no_vmtools: true - - name: "Get OS info inside guest OS" - include_tasks: ../utils/win_get_fullname.yml - - - name: "Print OS info" - ansible.builtin.debug: - msg: - - "Get guest fullname in guest OS: {{ os_fullname_guest }}" - - "Get OS architecture in guest OS: {{ guest_os_ansible_architecture }}" - - "VM guest ID is: {{ vm_guest_id }}" - - - name: "Get ESXi version info if not defined" - include_tasks: ../../common/esxi_get_version_build.yml - when: > - (esxi_version is undefined) or - (esxi_version == 'N/A') - - - name: "Get guest fullname from VM guest info" + - name: "Get VM guest info" include_tasks: ../../common/vm_get_guest_info.yml - - name: "Known issue - ignore incorrect guestID of Windows 11" + - name: "Set fact of the pre-defined guest OS info" + include_tasks: win_guest_os_info.yml + + - name: "Print current guest OS info" ansible.builtin.debug: msg: - - "The guestID of Windows 11 guest in guestinfo is empty on ESXi 7.0U3c. Ignore this known issue." - - "Please refer to https://knowledge.broadcom.com/external/article?legacyId=86517." - tags: - - known_issue - when: - - not guestinfo_guest_id - - esxi_version is defined and esxi_version - - esxi_version is version('7.0.3', '=') - - esxi_build is defined and esxi_build - - esxi_build == "19193900" - - "'Windows 11' in os_fullname_guest" - - vmtools_version is defined and vmtools_version - - vmtools_version is version('12.0.0', '>=') - - - name: "Check guest ID got from guest info is not empty" - ansible.builtin.assert: - that: - - guestinfo_guest_id - fail_msg: "Guest ID in guest info is '{{ guestinfo_guest_id }}', which should be a valid value firstly." - when: > - (not "'Windows 11' in os_fullname_guest") or - (esxi_version is undefined) or - (not esxi_version is version('7.0.3', '=')) or - (esxi_version is version('7.0.3', '=') and (esxi_build is undefined or esxi_build != "19193900")) or - (vmtools_version is undefined or vmtools_version is version('12.0.0', '<')) - - - name: "Set fact of the guest OS info list" - include_tasks: win_guest_os_info.yml + - "OS architecture got in guest OS: {{ guest_os_ansible_architecture }}" + - "OS fullname got in guest OS: {{ guest_os_ansible_distribution }}" + - "OS fullname got in VM guest info: {{ guestinfo_guest_full_name }}" + - "VM guest ID configured: {{ vm_guest_id }}" + - "VM guest ID got in VM guest info: {{ guestinfo_guest_id }}" - - name: "Check current guest OS in the guest OS info list" + - name: "Set fact of current OS name" + ansible.builtin.set_fact: + current_gos: "{{ guest_os_ansible_distribution.strip('Microsoft ') }}" + - name: "Get the current OS info in the pre-defined guest OS info list" + ansible.builtin.set_fact: + current_gos_info: "{{ win_gos_info | selectattr('win_guest', 'equalto', current_gos) }}" + - name: "Check current OS in the pre-defined guest OS info list" ansible.builtin.assert: that: - - win_gos_info | selectattr('win_guest', 'equalto', current_gos) + - current_gos_info fail_msg: - - "The defined Windows guest OS info list does not contain this OS version: {{ current_gos }}," - - "please check if this guest OS is supported and add it's info to the list accordingly." + - "The pre-defined guest OS info list does not contain this OS version: {{ current_gos }}," + - "please check whether this guest OS is supported and add it's info to the list accordingly." + + - name: "Check guest fullname in VM guest info" + include_tasks: check_guest_fullname_guest_info.yml + + - name: "Check guest ID in VM guest info" + include_tasks: check_guest_id_guest_info.yml rescue: - name: "Test case failure" include_tasks: ../../common/test_rescue.yml diff --git a/windows/check_os_fullname/get_previous_gos_info.yml b/windows/check_os_fullname/get_previous_gos_info.yml index 2c50c585b..74ac7ef5f 100644 --- a/windows/check_os_fullname/get_previous_gos_info.yml +++ b/windows/check_os_fullname/get_previous_gos_info.yml @@ -3,17 +3,9 @@ --- # Get the previous guest OS info in the pre-defined 'win_gos_info' # before the current guest OS version -- name: "Check current guest OS in the guest OS info list" - ansible.builtin.assert: - that: - - win_gos_info | selectattr('win_guest', 'equalto', current_gos) - fail_msg: - - "The defined Windows guest OS info list does not contain this OS version: {{ current_gos }}," - - "please check if this guest OS is supported and add it's info to the list accordingly." - - name: "Initialize the previous guest OS info" ansible.builtin.set_fact: - previous_gos: "" + previous_gos_info: "" - name: "Set fact of the Windows Server guest OS info" ansible.builtin.set_fact: @@ -43,8 +35,8 @@ - name: "Set fact of the previous guest OS" ansible.builtin.set_fact: - previous_gos: "{{ gos_list[current_gos_index | int + 1] }}" + previous_gos_info: "{{ gos_list[current_gos_index | int + 1] }}" when: current_gos_index | int < gos_list | length - 1 - name: "Print the previous guest OS info" - ansible.builtin.debug: var=previous_gos + ansible.builtin.debug: var=previous_gos_info diff --git a/windows/check_os_fullname/win_guest_os_info.yml b/windows/check_os_fullname/win_guest_os_info.yml index 17cbf6b22..e6c45d1e4 100644 --- a/windows/check_os_fullname/win_guest_os_info.yml +++ b/windows/check_os_fullname/win_guest_os_info.yml @@ -8,7 +8,9 @@ 'win_guest': 'Windows 10', 'win_guest_id': ['windows9Guest', 'windows9_64Guest'], 'win_guest_vmtools': '10.0.0', - 'win_guest_creation_esxi': '5.5.3', + 'win_guest_add_esxi': '5.5.3', + 'win_guest_creation_esxi': '6.0.0', + 'win_guest_creation_hwv': 11, 'win_guest_fullname': ["{{ 'Microsoft Windows 10 (' ~ guest_os_ansible_architecture ~ ')' }}"] }, { @@ -16,6 +18,7 @@ 'win_guest_id': ['windows11_64Guest'], 'win_guest_vmtools': '12.0.0', 'win_guest_creation_esxi': '8.0.0', + 'win_guest_creation_hwv': 20, 'win_guest_fullname': ['Microsoft Windows 11 (64-bit)'] }, { @@ -23,13 +26,16 @@ 'win_guest_id': [], 'win_guest_vmtools': 'NA', 'win_guest_creation_esxi': 'NA', + 'win_guest_creation_hwv': 'NA', 'win_guest_fullname': '[]' }, { 'win_guest': 'Windows Server 2016', 'win_guest_id': ['windows9Server64Guest'], 'win_guest_vmtools': '10.0.0', - 'win_guest_creation_esxi': '5.5.3', + 'win_guest_add_esxi': '5.5.3', + 'win_guest_creation_esxi': '6.0.0', + 'win_guest_creation_hwv': 11, 'win_guest_fullname': ['Microsoft Windows Server 2016 (64-bit)', 'Microsoft Windows Server 2016 or later (64-bit)'] }, { @@ -37,6 +43,7 @@ 'win_guest_id': ['windows2019srv_64Guest'], 'win_guest_vmtools': '11.0.5', 'win_guest_creation_esxi': '7.0.0', + 'win_guest_creation_hwv': 17, 'win_guest_fullname': ['Microsoft Windows Server 2019 (64-bit)'] }, { @@ -44,14 +51,16 @@ 'win_guest_id': ['Windows2019srvNext_64Guest'], 'win_guest_vmtools': '11.3.0', 'win_guest_creation_esxi': '7.0.1', + 'win_guest_creation_hwv': 18, 'win_guest_fullname': ['Microsoft Windows Server 2021 (64-bit)', 'Microsoft Windows Server 2022 (64-bit)'] }, { 'win_guest': 'Windows Server 2025', 'win_guest_id': ['Windows2022srvNext_64Guest'], - 'win_guest_vmtools': '12.0.5', + 'win_guest_vmtools': '12.1.0', 'win_guest_add_esxi': '8.0.0', 'win_guest_creation_esxi': '8.0.3', + 'win_guest_creation_hwv': 20, 'win_guest_fullname': ['Microsoft Windows Server 2025 (64-bit)'] }, { @@ -59,6 +68,7 @@ 'win_guest_id': [], 'win_guest_vmtools': 'NA', 'win_guest_creation_esxi': 'NA', + 'win_guest_creation_hwv': 'N/A', 'win_guest_fullname': [] } ] diff --git a/windows/guest_os_inplace_upgrade/check_after_gos_upgrade.yml b/windows/guest_os_inplace_upgrade/check_after_gos_upgrade.yml index 4bfca6ac8..74db698fb 100644 --- a/windows/guest_os_inplace_upgrade/check_after_gos_upgrade.yml +++ b/windows/guest_os_inplace_upgrade/check_after_gos_upgrade.yml @@ -3,7 +3,7 @@ --- - name: "Set fact of expected guest OS distribution" ansible.builtin.set_fact: - win_distr_expected: "{{ 'Microsoft ' ~ win_image_name | regex_search('Windows( Server)? ([0-9]+)') ~ ' ' ~ guest_os_edition }}" + win_distr_expected: "{{ 'Microsoft ' ~ win_image_name | regex_search('Windows( Server)? ([0-9]+)') }}" - name: "Get VMTools service status in guest OS" include_tasks: ../utils/win_get_service_status.yml diff --git a/windows/utils/get_windows_system_info.yml b/windows/utils/get_windows_system_info.yml index 6a94a7258..011ae20af 100644 --- a/windows/utils/get_windows_system_info.yml +++ b/windows/utils/get_windows_system_info.yml @@ -38,6 +38,11 @@ {{ (guest_os_ansible_distribution | regex_search('Microsoft Windows( Server)? ([0-9]+) (R2 )?(.*)', '\4') | first | regex_replace('insider|preview', '', ignorecase=True)).strip() }} when: guest_os_ansible_distribution +- name: "Set Windows guest OS distribution variable only contain OS name" + ansible.builtin.set_fact: + guest_os_ansible_distribution: >- + {{ (guest_os_ansible_distribution | regex_search('Microsoft Windows( Server)? ([0-9]+) (R2 )?')).strip() }} + - name: "Print Windows guest OS information" ansible.builtin.debug: msg: From 9fe6ff617b2d457b38fda664cd33bf3f33fd0adb Mon Sep 17 00:00:00 2001 From: dw035535 Date: Thu, 13 Feb 2025 06:48:45 +0000 Subject: [PATCH 5/8] refined test case Signed-off-by: dw035535 --- .../check_guest_fullname_guest_info.yml | 61 ---------------- .../check_guest_id_guest_info.yml | 24 ------ .../check_os_fullname/check_guest_info.yml | 73 +++++++++++++++++++ .../check_os_fullname/check_os_fullname.yml | 13 ++-- .../check_os_fullname/check_os_fullname_2.yml | 16 ---- windows/check_os_fullname/win10_fullname.yml | 12 --- windows/check_os_fullname/win11_fullname.yml | 41 ----------- .../win11_guest_info_exception.yml | 23 ++++++ .../check_os_fullname/win_guest_os_info.yml | 2 +- .../winsrv2016orlater_fullname.yml | 15 ---- .../check_os_fullname/winsrv2019_fullname.yml | 12 --- .../check_os_fullname/winsrv2022_fullname.yml | 43 ----------- .../check_os_fullname/winsrvnext_fullname.yml | 47 ------------ 13 files changed, 105 insertions(+), 277 deletions(-) delete mode 100644 windows/check_os_fullname/check_guest_fullname_guest_info.yml delete mode 100644 windows/check_os_fullname/check_guest_id_guest_info.yml create mode 100644 windows/check_os_fullname/check_guest_info.yml delete mode 100644 windows/check_os_fullname/check_os_fullname_2.yml delete mode 100644 windows/check_os_fullname/win10_fullname.yml delete mode 100644 windows/check_os_fullname/win11_fullname.yml create mode 100644 windows/check_os_fullname/win11_guest_info_exception.yml delete mode 100644 windows/check_os_fullname/winsrv2016orlater_fullname.yml delete mode 100644 windows/check_os_fullname/winsrv2019_fullname.yml delete mode 100644 windows/check_os_fullname/winsrv2022_fullname.yml delete mode 100644 windows/check_os_fullname/winsrvnext_fullname.yml diff --git a/windows/check_os_fullname/check_guest_fullname_guest_info.yml b/windows/check_os_fullname/check_guest_fullname_guest_info.yml deleted file mode 100644 index 805ebb0e2..000000000 --- a/windows/check_os_fullname/check_guest_fullname_guest_info.yml +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2025 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause ---- -# Get supported for create guest IDs -- name: "Get supported guest IDs on ESXi {{ esxi_version }} with hardware version {{ vm_hardware_version_num }}" - include_tasks: ../../common/esxi_get_guest_ids.yml - vars: - esxi_hardware_version: "{{ vm_hardware_version_num }}" - -# Set expected guest ID corresponding to current OS -- name: "Set fact of expected guest ID of current {{ guest_os_ansible_architecture }} OS" - ansible.builtin.set_fact: - current_os_guest_id: "{{ (guest_os_ansible_architecture == '64-bit' | ternary(current_gos_info['win_guest_id'] | select('match', '.*64Guest'), current_gos_info['win_guest_id'] | reject('match', '.*64Guest')))[0] }}" - -# Expected guest ID in supported guest IDs list -- name: "Check guest ID and fullname in VM guest info" - ansible.builtin.assert: - that: - - guestinfo_guest_id == vm_guest_id - - guestinfo_guest_id == current_os_guest_id - - guestinfo_guest_full_name in current_gos_info['win_guest_fullname'] - fail_msg: - - "Guest ID in VM guest info '{{ guestinfo_guest_id }}' should be equal to the configured guest ID '{{ vm_guest_id }}'," - - "Guest ID in VM guest info '{{ guestinfo_guest_id }}' should be equal to the expected one '{{ current_os_guest_id }}'," - - "Guest fullname in VM guest info '{{ guestinfo_guest_full_name }}' should be in the expected list '{{ current_gos_info['win_guest_fullname'] }}'." - when: current_os_guest_id in esxi_guest_ids - -# Expected guest ID not in supported guest IDs list -- name: "Guest ID is not supported for create on ESXi {{ esxi_version }}" - when: current_os_guest_id not in esxi_guest_ids - block: - - name: "Get the previous OS info in the pre-defined guest OS info list" - include_tasks: get_previous_gos_info.yml - - # Set expected guest ID corresponding to previous OS version - - name: "Set fact of expected guest ID of previous {{ guest_os_ansible_architecture }} OS" - ansible.builtin.set_fact: - previous_os_guest_id: "{{ (guest_os_ansible_architecture == '64-bit' | ternary(previous_gos_info['win_guest_id'] | select('match', '.*64Guest'), previous_gos_info['win_guest_id'] | reject('match', '.*64Guest')))[0] }}" - - - name: "Check VM configured guest ID is the previous guest ID" - ansible.builtin.assert: - that: - - vm_guest_id == previous_os_guest_id - fail_msg: - - "VM guest ID '{{ vm_guest_id }}' is not configured to the one of the previous OS version: {{ previous_os_guest_id }}," - - "since guest ID '{{ current_os_guest_id }}' of current OS is not found in the supported for create guest IDs on ESXi." - -# Guest ID is defined while not supported for create -- name: "Set fact of the conditions guest OS is recognized" - ansible.builtin.set_fact: - current_os_recognized: true - configured_pre_guest_id: true - when: - - current_gos_info.win_guest_add_esxi is defined and current_gos_info.win_guest_add_esxi - - esxi_version is version(current_gos_info.win_guest_add_esxi, '>=') - - esxi_version is version(current_gos_info.win_guest_creation_esxi, '<') - - vmtools_version is version(current_gos_info.win_guest_vmtools, '>=') - -# Current ESXi version does not contain the current OS defination -# 1. Current VMware Tools version can recognize the current OS -# 2. Current VMware Tools version can not recognize the current OS diff --git a/windows/check_os_fullname/check_guest_id_guest_info.yml b/windows/check_os_fullname/check_guest_id_guest_info.yml deleted file mode 100644 index 6c7c8359f..000000000 --- a/windows/check_os_fullname/check_guest_id_guest_info.yml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2025 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause ---- -- name: "Set fact of the condidtions of the known issue on Windows 11" - ansible.builtin.set_fact: - win11_known_issue: "{{ os_fullname_guest is search('Windows 11') and esxi_version is version('7.0.3', '=') and esxi_build == '19193900' and vmtools_version is version('12.0.0', '>=') }}" - -- name: "Known issue - incorrect/empty guestID in guest info of Windows 11" - ansible.builtin.debug: - msg: - - "The guestID of Windows 11 guest in guestinfo is empty on ESXi 7.0U3c. Ignore this known issue." - - "Please refer to https://knowledge.broadcom.com/external/article?legacyId=86517." - tags: - - known_issue - when: - - win11_known_issue - - not guestinfo_guest_id - -- name: "Check guest ID got from guest info is not empty" - ansible.builtin.assert: - that: - - guestinfo_guest_id - fail_msg: "Guest ID in guest info is '{{ guestinfo_guest_id }}', which should be a valid value firstly." - when: not win11_known_issue diff --git a/windows/check_os_fullname/check_guest_info.yml b/windows/check_os_fullname/check_guest_info.yml new file mode 100644 index 000000000..7954f37aa --- /dev/null +++ b/windows/check_os_fullname/check_guest_info.yml @@ -0,0 +1,73 @@ +# Copyright 2025 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause +--- +- name: "Initialize the facts of expected configured guest ID and guest fullname" + ansible.builtin.set_fact: + current_guest_id_expected: false + current_os_recognized: false + +- name: "Get supported guest IDs on ESXi {{ esxi_version }} with hardware version {{ vm_hardware_version_num }}" + include_tasks: ../../common/esxi_get_guest_ids.yml + vars: + esxi_hardware_version: "{{ vm_hardware_version_num }}" + +# Set expected guest ID corresponding to current OS +- name: "Set fact of expected guest ID of current {{ guest_os_ansible_architecture }} OS" + ansible.builtin.set_fact: + current_os_guest_id: "{{ (guest_os_ansible_architecture == '64-bit' | ternary(current_gos_info.win_guest_id | select('match', '.*64Guest'), current_gos_info.win_guest_id | reject('match', '.*64Guest')))[0] }}" + +- name: "Get the previous OS info in the pre-defined guest OS info list" + include_tasks: get_previous_gos_info.yml + +# Set expected guest ID corresponding to previous OS version +- name: "Set fact of expected guest ID of previous {{ guest_os_ansible_architecture }} OS" + ansible.builtin.set_fact: + previous_os_guest_id: "{{ (guest_os_ansible_architecture == '64-bit' | ternary(previous_gos_info.win_guest_id | select('match', '.*64Guest'), previous_gos_info.win_guest_id' | reject('match', '.*64Guest')))[0] }}" + +# VM configured guest ID should be the current OS guest ID when it's defined +# and supported for create on ESXi +- name: "Set fact of the current guest ID is the expected configured VM guest ID" + ansible.builtin.set_fact: + current_guest_id_expected: true + when: + - esxi_version is version(current_gos_info.win_guest_creation_esxi, '>=') + - vm_hardware_version_num | int >= current_gos_info.win_guest_creation_hwv | int + +# Guest OS can be recognized +- name: "Set fact of the current OS fullname is the expected guest OS fullname" + ansible.builtin.set_fact: + current_os_recognized: true + when: > + (esxi_version is version(current_gos_info.win_guest_creation_esxi, '>=')) or + (current_gos_info.win_guest_add_esxi is defined and + esxi_version is version(current_gos_info.win_guest_add_esxi, '>=') and + esxi_version is version(current_gos_info.win_guest_creation_esxi, '<') + vmtools_version is version(current_gos_info.win_guest_vmtools, '>=')) + +# Guest ID of previous OS version is configured +- name: "Check guest ID and fullname in VM guest info" + ansible.builtin.assert: + that: + - vm_guest_id == previous_os_guest_id + - guestinfo_guest_id == (current_os_recognized | ternary(current_os_guest_id, vm_guest_id)) + - guestinfo_guest_full_name in (current_os_recognized | ternary(current_gos_info.win_guest_fullname, previous_gos_info.win_guest_fullname)) + fail_msg: + - "VM guest ID configured '{{ vm_guest_id }}' should be the guest ID corresponding to previous OS version '{{ previous_os_guest_id }}'," + - "Guest ID in VM guest info '{{ guestinfo_guest_id }}' should be equal to '{{ current_os_recognized | ternary(current_os_guest_id, vm_guest_id) }}'," + - "Guest fullname in VM guest info '{{ guestinfo_guest_full_name }}' should be in '{{ current_os_recognized | ternary(current_gos_info.win_guest_fullname, previous_gos_info.win_guest_fullname) }}'." + when: + - not current_guest_id_expected + +# Guest ID of current OS version is configured +- name: "Check guest ID and fullname in VM guest info" + ansible.builtin.assert: + that: + - vm_guest_id == current_os_guest_id + - guestinfo_guest_id == vm_guest_id + - guestinfo_guest_full_name in current_gos_info['win_guest_fullname'] + fail_msg: + - "VM guest ID configured '{{ vm_guest_id }}' should be the guest ID corresponding to current OS version '{{ current_os_guest_id }}'," + - "Guest ID in VM guest info '{{ guestinfo_guest_id }}' should be equal to the configured guest ID '{{ vm_guest_id }}'," + - "Guest fullname in VM guest info '{{ guestinfo_guest_full_name }}' should be in the expected list '{{ current_gos_info['win_guest_fullname'] }}'." + when: + - current_guest_id_expected diff --git a/windows/check_os_fullname/check_os_fullname.yml b/windows/check_os_fullname/check_os_fullname.yml index c73b893ab..b2d00cc60 100644 --- a/windows/check_os_fullname/check_os_fullname.yml +++ b/windows/check_os_fullname/check_os_fullname.yml @@ -24,7 +24,7 @@ - name: "Set fact of the pre-defined guest OS info" include_tasks: win_guest_os_info.yml - - name: "Print current guest OS info" + - name: "Print the guest OS info before checking" ansible.builtin.debug: msg: - "OS architecture got in guest OS: {{ guest_os_ansible_architecture }}" @@ -36,9 +36,11 @@ - name: "Set fact of current OS name" ansible.builtin.set_fact: current_gos: "{{ guest_os_ansible_distribution.strip('Microsoft ') }}" + - name: "Get the current OS info in the pre-defined guest OS info list" ansible.builtin.set_fact: current_gos_info: "{{ win_gos_info | selectattr('win_guest', 'equalto', current_gos) }}" + - name: "Check current OS in the pre-defined guest OS info list" ansible.builtin.assert: that: @@ -47,11 +49,12 @@ - "The pre-defined guest OS info list does not contain this OS version: {{ current_gos }}," - "please check whether this guest OS is supported and add it's info to the list accordingly." - - name: "Check guest fullname in VM guest info" - include_tasks: check_guest_fullname_guest_info.yml + - name: "Check whether meet the conditions of known issue" + include_tasks: win11_guest_info_exception.yml - - name: "Check guest ID in VM guest info" - include_tasks: check_guest_id_guest_info.yml + - name: "Check guest fullname in VM guest info" + include_tasks: check_guest_info.yml + when: win11_70u3c_exception is undefined rescue: - name: "Test case failure" include_tasks: ../../common/test_rescue.yml diff --git a/windows/check_os_fullname/check_os_fullname_2.yml b/windows/check_os_fullname/check_os_fullname_2.yml deleted file mode 100644 index 61b39d77d..000000000 --- a/windows/check_os_fullname/check_os_fullname_2.yml +++ /dev/null @@ -1,16 +0,0 @@ -# ESXi version >= win_guest_add_esxi (or win_guest_creation_esxi) -# 1. Installed VMware Tools >= win_guest_vmtools -# > expected guest info - -# 2. Installed VMware Tools < win_guest_vmtools -# > configured guest ID should be the expected guest ID -# > guest ID corresponding guest info - -# ESXi version < win_guest_add_esxi (or win_guest_creation_esxi) -# 1. Installed VMware Tools >= win_guest_vmtools -# > configured guest ID should be the previous guest ID -# > guest ID corresponding guest info - -# 2. Installed VMware Tools < win_guest_vmtools -# > configured guest ID should be the previous guest ID -# > guest ID corresponding guest info diff --git a/windows/check_os_fullname/win10_fullname.yml b/windows/check_os_fullname/win10_fullname.yml deleted file mode 100644 index 1379db52c..000000000 --- a/windows/check_os_fullname/win10_fullname.yml +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2021-2024 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause ---- -# VM guest ID 'Windows9_64Guest' and 'Windows9Guest' is used for -# 'Windows 10' when ESXi >= 6.0.0 and hardware version >= 11. -# -- name: "Set fact of guest fullname for Windows 10 on ESXi >= 6.0.0" - ansible.builtin.set_fact: - expected_guest_fullname: "{{ 'Microsoft Windows 10 (' ~ guest_os_ansible_architecture ~ ')' }}" - when: - - esxi_version is version('6.0.0', '>=') - - (vm_guest_id == "windows9_64Guest") or (vm_guest_id == "windows9Guest") diff --git a/windows/check_os_fullname/win11_fullname.yml b/windows/check_os_fullname/win11_fullname.yml deleted file mode 100644 index 8274da3c9..000000000 --- a/windows/check_os_fullname/win11_fullname.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2021-2024 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause ---- -# VM guest ID 'TBD' is used for 'Windows 11' when -# ESXi > 7.0.3 and hardware version > 19. -# -# For VMware Tools version >= 12.0.0 -- block: - - name: "Set expected guest fullname for Windows 11 on ESXi > 7.0.3" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows 11 (64-bit)" - when: esxi_version is version('7.0.3', '>') - - # On ESXi 7.0U3c, guest fullname is 'Windows 11 Enterprise, 64-bit (Build xxxxx)' - - name: "Set expected guest fullname for Windows 11 on ESXi 7.0U3c" - ansible.builtin.set_fact: - expected_guest_fullname: "Windows 11" - when: - - esxi_version is version('7.0.3', '=') - - esxi_build == "19193900" - - - name: "Set expected guest fullname for Windows 11 on ESXi < 7.0.3" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows 10 (64-bit)" - when: > - (esxi_version is version('7.0.3', '<=') and esxi_build != "19193900" and esxi_version is version('7.0.0', '>=')) or - (esxi_version is version('7.0.0', '<') and esxi_version is version('6.7.0', '=') and esxi_update_version | int >= 2) - when: vmtools_version is version('12.0.0', '>=') - -# For VMware Tools version < 12.0.0 -- block: - - name: "Set expected guest fullname for Windows 11 with VMware Tools < 12.0.0" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows 10 (64-bit)" - when: vm_guest_id == "windows9_64Guest" - - - name: "Set expected guest fullname for Windows 11 with VMware Tools < 12.0.0" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows 11 (64-bit)" - when: vm_guest_id == "windows11_64Guest" - when: vmtools_version is version('12.0.0', '<') diff --git a/windows/check_os_fullname/win11_guest_info_exception.yml b/windows/check_os_fullname/win11_guest_info_exception.yml new file mode 100644 index 000000000..8a67bd4eb --- /dev/null +++ b/windows/check_os_fullname/win11_guest_info_exception.yml @@ -0,0 +1,23 @@ +# Copyright 2025 VMware, Inc. +# SPDX-License-Identifier: BSD-2-Clause +--- +# On ESXi 7.0U3c, guest fullname is 'Windows 11 Enterprise, 64-bit (Build xxxxx)', +# guest ID is empty. +# +- name: "Set fact of the exception of Windows 11 guest fullname" + ansible.builtin.set_fact: + win11_70u3c_exception: true + when: + - guest_os_ansible_distribution is search('Windows 11') + - esxi_version is version('7.0.3', '=') + - esxi_build == "19193900" + - vmtools_version is version('12.0.0', '>=') + +- name: "Known issue - incorrect/empty guestID in guest info of Windows 11" + ansible.builtin.debug: + msg: + - "The guestID of Windows 11 guest in guestinfo is empty on ESXi 7.0U3c. Ignore this known issue." + - "Please refer to https://knowledge.broadcom.com/external/article?legacyId=86517." + tags: + - known_issue + when: win11_70u3c_exception is defined and win11_70u3c_exception diff --git a/windows/check_os_fullname/win_guest_os_info.yml b/windows/check_os_fullname/win_guest_os_info.yml index e6c45d1e4..4864aa7a7 100644 --- a/windows/check_os_fullname/win_guest_os_info.yml +++ b/windows/check_os_fullname/win_guest_os_info.yml @@ -57,7 +57,7 @@ { 'win_guest': 'Windows Server 2025', 'win_guest_id': ['Windows2022srvNext_64Guest'], - 'win_guest_vmtools': '12.1.0', + 'win_guest_vmtools': '12.0.5', 'win_guest_add_esxi': '8.0.0', 'win_guest_creation_esxi': '8.0.3', 'win_guest_creation_hwv': 20, diff --git a/windows/check_os_fullname/winsrv2016orlater_fullname.yml b/windows/check_os_fullname/winsrv2016orlater_fullname.yml deleted file mode 100644 index 8492ac77e..000000000 --- a/windows/check_os_fullname/winsrv2016orlater_fullname.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2021-2024 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause ---- -# VM guest ID "Windows9Server64Guest" on ESXi version -# >= 6.5U3 or 6.7U2 and < 7.0.0, the guest OS fullname is -# "Microsoft Windows Server 2016 or later (64-bit)". -# On ESXi version < 6.5U3, or 6.7U2 and > 6.5GA, the guest OS -# fullname is "Microsoft Windows Server 2016 (64-bit)". -# -- name: "Set fact of expected guest fullname for Windows Server 2016" - ansible.builtin.set_fact: - expected_guest_fullname: - - "Microsoft Windows Server 2016 (64-bit)" - - "Microsoft Windows Server 2016 or later (64-bit)" - when: vm_guest_id == "windows9Server64Guest" diff --git a/windows/check_os_fullname/winsrv2019_fullname.yml b/windows/check_os_fullname/winsrv2019_fullname.yml deleted file mode 100644 index c5dc14913..000000000 --- a/windows/check_os_fullname/winsrv2019_fullname.yml +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2021-2024 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause ---- -# Guest ID 'Windows2019srv_64Guest' is introduced in ESXi -# version 7.0.0 and hardware version 17. -# -- name: "Set fact of guest fullname for Windows Server 2019 on ESXi >= 7.0.0" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2019 (64-bit)" - when: - - esxi_version is version('7.0.0', '>=') - - vm_guest_id == "windows2019srv_64Guest" diff --git a/windows/check_os_fullname/winsrv2022_fullname.yml b/windows/check_os_fullname/winsrv2022_fullname.yml deleted file mode 100644 index 305b9049d..000000000 --- a/windows/check_os_fullname/winsrv2022_fullname.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2021-2024 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause ---- -# VM guest ID 'Windows2019srvNext_64Guest' for 'Windows Server 2022' -# is introduced in ESXi 7.0.2 and hardware version 19. -# -# For VMware Tools version >= 11.3.0 -- block: - - name: "Set fact of expected guest fullname for Windows Server 2022 on ESXi >= 6.7U2" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2016 or later (64-bit)" - when: - - esxi_version is version('6.7.0', '=') - - esxi_update_version | int >= 2 - - name: "Set fact of expected guest fullname for Windows Server 2022 on ESXi 7.0.0" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2019 (64-bit)" - when: esxi_version is version('7.0.0', '=') - - name: "Set fact of expected guest fullname for Windows Server 2022 on ESXi 7.0.1" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2021 (64-bit)" - when: esxi_version is version('7.0.1', '=') - - name: "Set fact of expected guest fullname for Windows Server 2022 on ESXi >= 7.0.2" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2022 (64-bit)" - when: esxi_version is version('7.0.2', '>=') - when: vmtools_version is version('11.3.0', '>=') - -# For VMWare tools version < 11.3.0 -- block: - - name: "Set fact of expected guest fullname for Windows Server 2022" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2016 or later (64-bit)" - when: vm_guest_id == "windows9Server64Guest" - - name: "Set fact of expected guest fullname for Windows Server 2022" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2019 (64-bit)" - when: vm_guest_id == "windows2019srv_64Guest" - - name: "Set fact of expected guest fullname for Windows Server 2022" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2022 (64-bit)" - when: vm_guest_id == "windows2019srvNext_64Guest" - when: vmtools_version is version('11.3.0', '<') diff --git a/windows/check_os_fullname/winsrvnext_fullname.yml b/windows/check_os_fullname/winsrvnext_fullname.yml deleted file mode 100644 index 2b0fa1a74..000000000 --- a/windows/check_os_fullname/winsrvnext_fullname.yml +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2022-2024 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause ---- -# VM guest ID 'TBD' for 'Windows Server vNext LTSC' -# will be introduced in ESXi 'TBD' and hardware version 'TBD'. -# -# Workaroud for Windows Server vNext LTSC testing, will change this when the -# OS release has an official name -- block: - - name: "Set fact of expected guest fullname for Windows Server vNext on ESXi 7.0.0" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2019 (64-bit)" - when: esxi_version is version('7.0.0', '=') - - name: "Set fact of expected guest fullname for Windows Server vNext on ESXi 7.0.1" - block: - - name: "When VMware Tools version is 12.0.5" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2021 (64-bit)" - when: vmtools_version is version('12.0.5', '=') - - name: "When VMware Tools version > 12.0.5" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2019 (64-bit)" - when: vmtools_version is version('12.0.5', '>') - when: esxi_version is version('7.0.1', '=') - - name: "Set fact of expected guest fullname for Windows Server vNext on ESXi 7.0.2" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2022 (64-bit)" - when: esxi_version is version('7.0.2', '=') - - name: "Set fact of expected guest fullname for Windows Server vNext on ESXi >= 7.0.3" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft {{ guestinfo_detailed_data.split(\"prettyName='\")[1].split(',')[0] }} (64-bit)" - when: - - esxi_version is version('7.0.3', '>=') - - guestinfo_detailed_data is defined and guestinfo_detailed_data - when: vmtools_version is version('12.0.5', '>=') - -# For VMWare tools version <= 12.0.5 -- block: - - name: "Set fact of expected guest fullname for Windows Server vNext" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2019 (64-bit)" - when: vm_guest_id == "windows2019srv_64Guest" - - name: "Set fact of expected guest fullname for Windows Server vNext" - ansible.builtin.set_fact: - expected_guest_fullname: "Microsoft Windows Server 2022 (64-bit)" - when: vm_guest_id == "windows2019srvNext_64Guest" - when: vmtools_version is version('12.0.5', '<') From 4655d1ce621e85077f15492a3f9fc13cecfbf638 Mon Sep 17 00:00:00 2001 From: dw035535 Date: Thu, 13 Feb 2025 08:30:38 +0000 Subject: [PATCH 6/8] fix indent issue Signed-off-by: dw035535 --- windows/check_os_fullname/check_os_fullname.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/windows/check_os_fullname/check_os_fullname.yml b/windows/check_os_fullname/check_os_fullname.yml index b2d00cc60..dce0aa10f 100644 --- a/windows/check_os_fullname/check_os_fullname.yml +++ b/windows/check_os_fullname/check_os_fullname.yml @@ -49,12 +49,12 @@ - "The pre-defined guest OS info list does not contain this OS version: {{ current_gos }}," - "please check whether this guest OS is supported and add it's info to the list accordingly." - - name: "Check whether meet the conditions of known issue" - include_tasks: win11_guest_info_exception.yml + - name: "Check whether meet the conditions of known issue" + include_tasks: win11_guest_info_exception.yml - - name: "Check guest fullname in VM guest info" - include_tasks: check_guest_info.yml - when: win11_70u3c_exception is undefined + - name: "Check guest fullname in VM guest info" + include_tasks: check_guest_info.yml + when: win11_70u3c_exception is undefined rescue: - name: "Test case failure" include_tasks: ../../common/test_rescue.yml From f6c9179efeb3a23bea644e0d2d0ec5b42172a8ef Mon Sep 17 00:00:00 2001 From: dw035535 Date: Wed, 12 Mar 2025 06:51:46 +0000 Subject: [PATCH 7/8] change exception Signed-off-by: dw035535 --- .../check_os_fullname/check_os_fullname.yml | 21 ++++++++++--------- ...guest_info.yml => check_vm_guest_info.yml} | 0 .../win11_guest_info_exception.yml | 8 +++++-- 3 files changed, 17 insertions(+), 12 deletions(-) rename windows/check_os_fullname/{check_guest_info.yml => check_vm_guest_info.yml} (100%) diff --git a/windows/check_os_fullname/check_os_fullname.yml b/windows/check_os_fullname/check_os_fullname.yml index dce0aa10f..915b23033 100644 --- a/windows/check_os_fullname/check_os_fullname.yml +++ b/windows/check_os_fullname/check_os_fullname.yml @@ -2,10 +2,10 @@ # SPDX-License-Identifier: BSD-2-Clause --- # Description: -# This test case is used for check VM guest fullname and guest ID -# are reported correctly in the VM guest info through VMware Tools. -# When VMware Tools is not installed or not running in VM, -# this test case result is 'Blocked'. +# This test case is used for checking VM guest OS fullname +# and guest OS ID are reported correctly in the VM guest info +# by VMware Tools. When VMware Tools is not installed or not +# running in the guest OS, this test case result is 'Blocked'. # - name: check_os_fullname hosts: localhost @@ -21,7 +21,7 @@ - name: "Get VM guest info" include_tasks: ../../common/vm_get_guest_info.yml - - name: "Set fact of the pre-defined guest OS info" + - name: "Set fact of the pre-defined guest OS info list" include_tasks: win_guest_os_info.yml - name: "Print the guest OS info before checking" @@ -32,6 +32,7 @@ - "OS fullname got in VM guest info: {{ guestinfo_guest_full_name }}" - "VM guest ID configured: {{ vm_guest_id }}" - "VM guest ID got in VM guest info: {{ guestinfo_guest_id }}" + - "VM hardware version: {{ vm_hardware_version }}" - name: "Set fact of current OS name" ansible.builtin.set_fact: @@ -45,15 +46,15 @@ ansible.builtin.assert: that: - current_gos_info - fail_msg: - - "The pre-defined guest OS info list does not contain this OS version: {{ current_gos }}," - - "please check whether this guest OS is supported and add it's info to the list accordingly." + fail_msg: > + "The pre-defined guest OS info list does not contain this OS version: {{ current_gos }}, + please check whether this guest OS is supported and add it to the list accordingly." - - name: "Check whether meet the conditions of known issue" + - name: "Handle Windows 11 known issue" include_tasks: win11_guest_info_exception.yml - name: "Check guest fullname in VM guest info" - include_tasks: check_guest_info.yml + include_tasks: check_vm_guest_info.yml when: win11_70u3c_exception is undefined rescue: - name: "Test case failure" diff --git a/windows/check_os_fullname/check_guest_info.yml b/windows/check_os_fullname/check_vm_guest_info.yml similarity index 100% rename from windows/check_os_fullname/check_guest_info.yml rename to windows/check_os_fullname/check_vm_guest_info.yml diff --git a/windows/check_os_fullname/win11_guest_info_exception.yml b/windows/check_os_fullname/win11_guest_info_exception.yml index 8a67bd4eb..94e546dd6 100644 --- a/windows/check_os_fullname/win11_guest_info_exception.yml +++ b/windows/check_os_fullname/win11_guest_info_exception.yml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: BSD-2-Clause --- # On ESXi 7.0U3c, guest fullname is 'Windows 11 Enterprise, 64-bit (Build xxxxx)', -# guest ID is empty. +# guest ID is empty in VM guest info. # - name: "Set fact of the exception of Windows 11 guest fullname" ansible.builtin.set_fact: @@ -12,6 +12,8 @@ - esxi_version is version('7.0.3', '=') - esxi_build == "19193900" - vmtools_version is version('12.0.0', '>=') + - guestinfo_guest_id == '' + - guestinfo_guest_full_name is search('Build') - name: "Known issue - incorrect/empty guestID in guest info of Windows 11" ansible.builtin.debug: @@ -20,4 +22,6 @@ - "Please refer to https://knowledge.broadcom.com/external/article?legacyId=86517." tags: - known_issue - when: win11_70u3c_exception is defined and win11_70u3c_exception + when: + - win11_70u3c_exception is defined + - win11_70u3c_exception From a86034a4bcbb31b66ba313725b87f10524dab261 Mon Sep 17 00:00:00 2001 From: dw035535 Date: Thu, 20 Mar 2025 05:56:28 +0000 Subject: [PATCH 8/8] matched OS info is list Signed-off-by: dw035535 --- windows/check_os_fullname/check_os_fullname.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/windows/check_os_fullname/check_os_fullname.yml b/windows/check_os_fullname/check_os_fullname.yml index 915b23033..84161ffd5 100644 --- a/windows/check_os_fullname/check_os_fullname.yml +++ b/windows/check_os_fullname/check_os_fullname.yml @@ -38,18 +38,22 @@ ansible.builtin.set_fact: current_gos: "{{ guest_os_ansible_distribution.strip('Microsoft ') }}" - - name: "Get the current OS info in the pre-defined guest OS info list" + - name: "Get OS info in the pre-defined guest OS info list matched current OS" ansible.builtin.set_fact: current_gos_info: "{{ win_gos_info | selectattr('win_guest', 'equalto', current_gos) }}" - name: "Check current OS in the pre-defined guest OS info list" ansible.builtin.assert: that: - - current_gos_info + - current_gos_info | length == 1 fail_msg: > "The pre-defined guest OS info list does not contain this OS version: {{ current_gos }}, please check whether this guest OS is supported and add it to the list accordingly." + - name: "Set fact of the matched current OS info" + ansible.builtin.set_fact: + current_gos_info: "{{ current_gos_info[0] }}" + - name: "Handle Windows 11 known issue" include_tasks: win11_guest_info_exception.yml