Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Windows] Add check usernames of vmtoolsd processes #517

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/get_guest_system_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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('') }}"
1 change: 1 addition & 0 deletions windows/utils/get_windows_system_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
70 changes: 45 additions & 25 deletions windows/wintools_complete_install_verify/verify_vmtools.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,73 @@
# Copyright 2021-2023 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
---
# Check VMware tools service is running and display the installed VMware tools
# version, get VMware tools installation log file.
# Check VMware Tools service is running and display the installed VMware Tools
# version, get VMware Tools installation log file.
#
- include_tasks: ../utils/win_get_path.yml
- name: "Get VMware Tools install log file path"
include_tasks: ../utils/win_get_path.yml
vars:
win_get_path_specified: '$env:temp\vminst.log'
- include_tasks: ../utils/win_get_file.yml
- name: "Fetch VMware Tools install log file"
include_tasks: ../utils/win_get_file.yml
vars:
win_get_file_src_path: "{{ win_get_path_absolute }}"
win_get_file_dst_path: "{{ current_test_log_folder }}"

# Check VMware tools service status
- include_tasks: ../utils/win_get_service_status.yml
- name: "Get VMware Tools service status"
include_tasks: ../utils/win_get_service_status.yml
vars:
win_service_name: "VMTools"
- name: Verify VMware tools service status is running
- name: "Verify VMware Tools service status is running"
ansible.builtin.assert:
that:
- service_status == "Running"
fail_msg: "VMTools service status is not Running"
success_msg: "VMTools service status is Running"
fail_msg: "VMTools service status: {{ service_status }}, which is not 'Running'."
success_msg: "VMTools service status is 'Running'."

# Get VMware tools version and build number
- include_tasks: ../utils/win_get_vmtools_version_build.yml
- name: "Print VMware Tools version and build"
- name: "Get VMware Tools version and build number"
include_tasks: ../utils/win_get_vmtools_version_build.yml
- name: "Print VMware Tools version and build number"
ansible.builtin.debug: var=vmtools_info_from_vmtoolsd

# Get VMware drivers list
- include_tasks: ../utils/win_get_vmtools_driver_list.yml
# Get VMware services list
- include_tasks: ../utils/win_get_vmtools_service_list.yml
- name: "Get VMware drivers list"
include_tasks: ../utils/win_get_vmtools_driver_list.yml

- name: "Get VMware services list"
include_tasks: ../utils/win_get_vmtools_service_list.yml
# Not all services are running, e.g., vmvss
- name: Display all services running status in guest OS
- name: "Display services running status in guest OS"
ansible.builtin.debug:
msg: "Service '{{ item.key }}' status is: {{ item.value }}"
# ansible.builtin.assert:
# that:
# - "{{ item.value == 'Running' }}"
# success_msg: "Service '{{ item.key }}' status is: {{ item.value }}"
# fail_msg: "Service '{{ item.key }}' status is: {{ item.value }}"
with_dict: "{{ vmtools_service_dict }}"

# Check problem device after VMware tools install
- include_tasks: ../utils/win_get_problem_device.yml
- 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 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 | 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
- name: "Check no problem device listed"
ansible.builtin.assert:
that:
- gos_has_problem_device is defined
- not gos_has_problem_device
fail_msg: "Problem devices were found on the system, please check listed problem devices: {{ gos_problem_device_list }}"
fail_msg: "Problem devices were found in guest OS, please check listed problem devices: {{ gos_problem_device_list }}"
success_msg: "No problem device is found in guest OS."