Skip to content
2 changes: 1 addition & 1 deletion common/esxi_get_guest_ids.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
vm_default_config_xpath: "/ConfigRoot/ConfigurationOption/guestOSDescriptor/e/id"

- name: "Get hardware version {{ esxi_hardware_version }} supported guest IDs on ESXi server"
xml:
community.general.xml:
path: "{{ vm_config_option_esx_hw }}"
xpath: "{{ vm_default_config_xpath }}"
content: text
Expand Down
2 changes: 2 additions & 0 deletions common/get_guest_system_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
vars:
gos_info_filter:
- 'ansible_architecture'
- 'ansible_architecture2'
- 'ansible_distribution*'
- 'ansible_kernel'
- 'ansible_os_family'
Expand All @@ -36,6 +37,7 @@
guest_os_ansible_distribution: "{{ guest_system_info.ansible_distribution | default('') }}"
guest_os_ansible_system: "{{ guest_system_info.ansible_system | default('') | lower }}"
guest_os_ansible_architecture: "{{ guest_system_info.ansible_architecture | default('') }}"
guest_os_ansible_architecture2: "{{ guest_system_info.ansible_architecture2 | default('') }}"
guest_os_ansible_distribution_ver: "{{ guest_system_info.ansible_distribution_version if guest_system_info.ansible_distribution != 'FreeBSD' else guest_system_info.ansible_kernel }}"
guest_os_ansible_distribution_major_ver: "{{ guest_system_info.ansible_distribution_major_version if 'ansible_distribution_major_version' in guest_system_info else guest_system_info.ansible_distribution_release.split('-')[0].split('.')[0] }}"
guest_os_ansible_distribution_minor_ver: |-
Expand Down
117 changes: 42 additions & 75 deletions windows/check_os_fullname/check_os_fullname.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,64 @@
# 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 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
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:
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
when: >
(esxi_version is undefined) or
(esxi_version == 'N/A')
- name: "Get VM guest info"
include_tasks: ../../common/vm_get_guest_info.yml

# Get guest fullname from VM guest info
- include_tasks: ../../common/vm_get_guest_info.yml
- name: "Set fact of the pre-defined guest OS info list"
include_tasks: win_guest_os_info.yml

- name: "Known issue - ignore incorrect guestID of Windows 11"
- name: "Print the guest OS info before checking"
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?articleId=313437."
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"
- "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 }}"
- "VM hardware version: {{ vm_hardware_version }}"

- name: "Set fact of current OS name"
ansible.builtin.set_fact:
current_gos: "{{ guest_os_ansible_distribution | regex_search('Windows( Server)? ([0-9]+)') }}"

- 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:
- 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', '<'))
- 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: Initialize the expected guest fullname
- name: "Set fact of the matched current OS info"
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"
current_gos_info: "{{ current_gos_info[0] }}"

# 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"
- name: "Handle Windows 11 known issue"
include_tasks: win11_guest_info_exception.yml

- ansible.builtin.debug:
msg: "Expected guest fullname on ESXi '{{ esxi_version }}': {{ expected_guest_fullname }}"
- name: "Verify guest fullname in guest info is expected"
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 }}."
- name: "Check guest fullname in VM guest info"
include_tasks: check_vm_guest_info.yml
when: win11_70u3c_exception is undefined
rescue:
- include_tasks: ../../common/test_rescue.yml
- name: "Test case failure"
include_tasks: ../../common/test_rescue.yml
80 changes: 80 additions & 0 deletions windows/check_os_fullname/check_vm_guest_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# 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 }}"

# VM configured guest ID should be the current OS guest ID when
# 1. ESXi version
# 2. VM hardware version
- 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 should 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 != current_gos_info.win_guest_creation_esxi) and
esxi_version is version(current_gos_info.win_guest_add_esxi, '>=') and
esxi_version is version(current_gos_info.win_guest_creation_esxi, '<') and
vmtools_version is version(current_gos_info.win_guest_vmtools, '>='))

# Set expected guest ID corresponding to the current OS
- name: "Set fact of expected guest ID of current {{ guest_os_ansible_architecture }} OS"
ansible.builtin.set_fact:
current_os_guest_id: >-
{%- if guest_os_ansible_architecture == '32-bit' -%}{{ (current_gos_info.win_guest_id | reject('match', '.*64Guest'))[0] }}
{%- else -%}{{ (current_gos_info.win_guest_id | select('match', '.*64Guest'))[0] }}
{%- endif -%}

- name: "Set expected guest ID corresponding to previous OS version"
when: not current_guest_id_expected
block:
- name: "Get the previous OS info in the pre-defined guest OS info list"
include_tasks: get_previous_gos_info.yml

- name: "Set fact of expected guest ID of previous {{ guest_os_ansible_architecture }} OS"
ansible.builtin.set_fact:
previous_os_guest_id: >-
{%- if guest_os_ansible_architecture == '32-bit' -%}{{ (previous_gos_info.win_guest_id | reject('match', '.*64Guest'))[0] }}
{%- else -%}{{ (previous_gos_info.win_guest_id | select('match', '.*64Guest'))[0] }}
{%- endif -%}

# 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
42 changes: 42 additions & 0 deletions windows/check_os_fullname/get_previous_gos_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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: "Initialize the previous guest OS info"
ansible.builtin.set_fact:
previous_gos_info: ""

- 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_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_info
27 changes: 27 additions & 0 deletions windows/check_os_fullname/win11_guest_info_exception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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 in VM guest info.
#
- 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', '>=')
- 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:
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
- win11_70u3c_exception
74 changes: 74 additions & 0 deletions windows/check_os_fullname/win_guest_os_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# 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: [
{
'win_guest': 'Windows 10',
'win_guest_id': ['windows9Guest', 'windows9_64Guest'],
'win_guest_vmtools': '10.0.0',
'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 ~ ')' }}"]
},
{
'win_guest': 'Windows 11',
'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)']
},
{
'win_guest': 'Windows next',
'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_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)']
},
{
'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_creation_hwv': 17,
'win_guest_fullname': ['Microsoft Windows Server 2019 (64-bit)']
},
{
'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_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_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)']
},
{
'win_guest': 'Windows Server next',
'win_guest_id': [],
'win_guest_vmtools': 'NA',
'win_guest_creation_esxi': 'NA',
'win_guest_creation_hwv': 'N/A',
'win_guest_fullname': []
}
]
Loading