diff --git a/common/get_guest_system_info.yml b/common/get_guest_system_info.yml index 6d04810d2..15df4ef88 100644 --- a/common/get_guest_system_info.yml +++ b/common/get_guest_system_info.yml @@ -26,6 +26,7 @@ - 'ansible_os_product_type' - 'ansible_pkg_mgr' - 'ansible_system' + - 'ansible_hostname' - name: "Set facts of guest OS system info" ansible.builtin.set_fact: @@ -43,3 +44,4 @@ guest_os_ansible_pkg_mgr: "{{ guest_system_info.ansible_pkg_mgr | default('') }}" guest_os_family: "{{ guest_system_info.ansible_os_family | default('') }}" guest_os_product_type: "{{ guest_system_info.ansible_os_product_type | default('') }}" + guest_os_hostname: "{{ guest_system_info.ansible_hostname | default('') }}" diff --git a/windows/utils/get_windows_system_info.yml b/windows/utils/get_windows_system_info.yml index 1208b8fdc..700e0aaaf 100644 --- a/windows/utils/get_windows_system_info.yml +++ b/windows/utils/get_windows_system_info.yml @@ -55,6 +55,7 @@ - "Guest OS product type: {{ guest_os_product_type }}" - "Guest OS build number: {{ guest_os_build_num }}" - "Guest OS edition: {{ guest_os_edition }}" + - "Guest OS hostname: {{ guest_os_hostname }}" - "Guest OS should contain inbox drivers: {{ guest_os_with_inbox_drivers }}" - name: "Set fact of VM guest OS type" diff --git a/windows/utils/win_get_vmtools_process_info.yml b/windows/utils/win_get_vmtools_process_info.yml deleted file mode 100644 index 55e51652f..000000000 --- a/windows/utils/win_get_vmtools_process_info.yml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2023 VMware, Inc. -# SPDX-License-Identifier: BSD-2-Clause ---- -# Get VMware Tools processes in Windows guest OS -# -- name: "Initialize the fact of VMware Tools processes info" - ansible.builtin.set_fact: - vmtools_process_dict: {} - -- name: "Get VMware Tools processes info" - include_tasks: win_execute_cmd.yml - vars: - win_powershell_cmd: "Get-Process vmtoolsd -IncludeUserName | select UserName, ProcessName, Id | fl" - -- name: "Set VMware Tools processes info" - when: - - win_powershell_cmd_output.stdout_lines is defined - - win_powershell_cmd_output.stdout_lines | length != 0 - block: - - name: "Set fact of VMware Tools processes info dict" - ansible.builtin.set_fact: - vmtools_process_dict: "{{ vmtools_process_dict | combine({item.split()[0].strip(): item.split()[1].strip()}) }}" - when: item | length != 0 - with_items: "{{ win_powershell_cmd_output.stdout_lines }}" - -- name: "Print VMware Tools processes info dict" - ansible.builtin.debug: - msg: "Get VMware Tools processes in guest OS: {{ vmtools_process_dict }}" diff --git a/windows/wintools_complete_install_verify/verify_vmtools.yml b/windows/wintools_complete_install_verify/verify_vmtools.yml index 1867c5246..238e3d70d 100644 --- a/windows/wintools_complete_install_verify/verify_vmtools.yml +++ b/windows/wintools_complete_install_verify/verify_vmtools.yml @@ -41,19 +41,26 @@ msg: "Service '{{ item.key }}' status is: {{ item.value }}" with_dict: "{{ vmtools_service_dict }}" -- name: "Get the user names of VMware Tools processes" +- name: "Set fact of expected usernames of VMware Tools processes" + ansible.builtin.set_fact: + win_vmtoolsd_username_list: ["NT AUTHORITY\SYSTEM", "{{ guest_os_hostname }}\\{{ vm_username }}"] +- name: "Get usernames of VMware Tools processes in guest OS" include_tasks: ../utils/win_execute_cmd.yml vars: win_powershell_cmd: "(Get-Process vmtoolsd -IncludeUserName).UserName" -- name: "Check the user names of VMware Tools processes" +- name: "Check usernames of VMware Tools processes" ansible.builtin.assert: that: - win_powershell_cmd_output.stdout_lines is defined - win_powershell_cmd_output.stdout_lines | length == 2 - - win_powershell_cmd_output.stdout_lines[0] is match("*\SYSTEM") - - win_powershell_cmd_output.stdout_lines[1] is match("*\vm_username") - fail_msg: "Get user names '{{ win_powershell_cmd_output.stdout_lines | default('') }}', which are not expected '*\SYSTEM' and '*\{{ vm_username }}'." - success_msg: "Get user names '*\SYSTEM' and '*\{{ vm_username }}' of VMware Tools processes." + - win_powershell_cmd_output.stdout_lines | sort == win_vmtoolsd_username_list | sort + fail_msg: >- + Get usernames of 'vmtoolsd' processes: + {{ win_powershell_cmd_output.stdout_lines | default('') }}, + expected ones are {{ win_vmtoolsd_username_list }}. + success_msg: >- + Get usernames of 'vmtoolsd' processes: + {{ win_powershell_cmd_output.stdout_lines }}. - name: "Get problem device after VMware Tools install" include_tasks: ../utils/win_get_problem_device.yml