Skip to content

Commit

Permalink
[Windows] Add uninstall OneDrive and OneDriveSync appx package in GOS…
Browse files Browse the repository at this point in the history
…C test cases (vmware#225)

* add workaround or GOSC failure

Signed-off-by: dianew <[email protected]>
  • Loading branch information
Tomorrow9 authored Jan 21, 2022
1 parent 1a4f43c commit 07d64ae
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
27 changes: 22 additions & 5 deletions windows/guest_customization/uninstall_onedrive.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
# 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:
one_drive_appx_package_name: "{{ win_powershell_cmd_output.stdout_lines[0] }}"
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:
Expand Down
10 changes: 10 additions & 0 deletions windows/guest_customization/win_gosc_prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions windows/utils/win_check_file_exist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

0 comments on commit 07d64ae

Please sign in to comment.