From 07d64ae7454f3d264066cf196d16fd51ca728be0 Mon Sep 17 00:00:00 2001 From: Diane Wang <41371902+Tomorrow9@users.noreply.github.com> Date: Fri, 21 Jan 2022 07:23:34 +0000 Subject: [PATCH] [Windows] Add uninstall OneDrive and OneDriveSync appx package in GOSC test cases (#225) * add workaround or GOSC failure Signed-off-by: dianew --- .../uninstall_onedrive.yml | 27 +++++++++++++++---- .../guest_customization/win_gosc_prepare.yml | 10 +++++++ windows/utils/win_check_file_exist.yml | 10 +++---- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/windows/guest_customization/uninstall_onedrive.yml b/windows/guest_customization/uninstall_onedrive.yml index a06273f7f..c3948d59d 100644 --- a/windows/guest_customization/uninstall_onedrive.yml +++ b/windows/guest_customization/uninstall_onedrive.yml @@ -1,18 +1,34 @@ # Copyright 2022 VMware, Inc. # SPDX-License-Identifier: BSD-2-Clause --- -- name: Set fact of uninstall OneDrive command +- name: "Set fact of OneDrive setup exe file path for Windows 11 GA" set_fact: - uninstall_one_drive: "C:\\Windows\\SysWOW64\\OneDriveSetup.exe /uninstall" + one_drive_setup_exe: "C:\\Windows\\SysWOW64\\OneDriveSetup.exe" + when: + - guest_os_ansible_distribution_ver is defined + - guest_os_ansible_distribution_ver == '10.0.22000.0' +- name: Set fact of OneDrive setup exe file path + set_fact: + one_drive_setup_exe: "C:\\Windows\\System32\\OneDriveSetup.exe" + when: one_drive_setup_exe is undefined +# Check OneDrive setup exe file exists +- include_tasks: ../utils/win_check_file_exist.yml + vars: + win_check_file_exist_file: "{{ one_drive_setup_exe }}" + +# Uninstall OneDrive when predefined setup exe file exists - include_tasks: ../utils/win_execute_cmd.yml vars: - win_powershell_cmd: "{{ uninstall_one_drive }}" + win_powershell_cmd: "Start-Process -NoNewWindow -Wait -FilePath {{ one_drive_setup_exe }} -ArgumentList '/uninstall'" + when: + - win_check_file_exist_result is defined + - win_check_file_exist_result # Get installed OneDrive appx package name - include_tasks: ../utils/win_execute_cmd.yml vars: - win_powershell_cmd: "(Get-AppxPackage -AllUsers | Where PublisherId -eq 8wekyb3d8bbwe | Where PackageFullName -Like '*OneDriveSync*').PackageFullName" + win_powershell_cmd: "(Get-AppxPackage -AllUsers | Where PackageFullName -Like '*OneDriveSync*').PackageFullName" - name: Set fact of OneDrive Sync appx package name set_fact: @@ -20,7 +36,8 @@ when: - win_powershell_cmd_output is defined - "'stdout_lines' in win_powershell_cmd_output" - - win_powershell_cmd_output.stdout_lines | len != 0 + - win_powershell_cmd_output.stdout_lines | length != 0 + - win_powershell_cmd_output.stdout_lines[0] - include_tasks: ../utils/win_execute_cmd.yml vars: diff --git a/windows/guest_customization/win_gosc_prepare.yml b/windows/guest_customization/win_gosc_prepare.yml index 135b81773..bcc2f4bf9 100644 --- a/windows/guest_customization/win_gosc_prepare.yml +++ b/windows/guest_customization/win_gosc_prepare.yml @@ -48,6 +48,16 @@ - debug: msg: "Windows GOSC log files in Windows dir: {{ win_dir }}" +# Uninstall OneDrive in Windows 11 for the known 3rd-party issue +# Paramter 'keep_onedrive' is used for internal testing on insider preview build +- include_tasks: uninstall_onedrive.yml + when: + - keep_onedrive is undefined or not keep_onedrive + - guest_os_ansible_distribution_ver is defined + - guest_os_ansible_distribution_ver is version('10.0.22000.0', '>=') + - guest_os_product_type is defined + - guest_os_product_type | lower == 'client' + # Shutdown guest OS before execute guest customization - include_tasks: ../utils/win_shutdown_restart.yml vars: diff --git a/windows/utils/win_check_file_exist.yml b/windows/utils/win_check_file_exist.yml index 36d9b9e88..7048432b2 100644 --- a/windows/utils/win_check_file_exist.yml +++ b/windows/utils/win_check_file_exist.yml @@ -15,18 +15,18 @@ win_stat: path: "{{ win_check_file_exist_file }}" delegate_to: "{{ vm_guest_ip }}" - register: file_info + register: win_check_file_info ignore_errors: True - name: Display the returned file info - debug: var=file_info + debug: var=win_check_file_info when: enable_debug is defined and enable_debug - name: Set fact of file existence set_fact: win_check_file_exist_result: True when: - - "'stat' in file_info" - - "'exists' in file_info.stat" - - file_info.stat.exists + - "'stat' in win_check_file_info" + - "'exists' in win_check_file_info.stat" + - win_check_file_info.stat.exists - debug: msg: "File '{{ win_check_file_exist_file }}' is in guest OS: {{ win_check_file_exist_result }}"