Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Yanan Shen <[email protected]>
  • Loading branch information
123lzxm committed Jan 8, 2024
1 parent 70cf886 commit ba0e085
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion env_setup/env_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
vm_cleaned_up: true
vm_exists: false

- name: "Restore base snapshot for windows update installation"
- name: "Restore base snapshot for Windows Update installation"
when:
- win_update_snapshot_name is defined
- win_update_snapshot_name
Expand Down
10 changes: 10 additions & 0 deletions vars/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ base_snapshot_name: "BaseSnapshot"
#
# http_proxy_localhost: myproxy.company.com:8080

# To keep sensitive values out of your logs, such as passwords and usernames, mark tasks that expose them
# with the "no_log: True" attribute.
# This var is the value for attribute no_log.
# Default value is false.
#
# hide_secrets: false

#####################################
# Testbed parameters
#####################################
Expand Down Expand Up @@ -359,6 +366,9 @@ windows_product_key_upgrade: "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
windows_msu_share_point: ''
# The path of the .msu file in windows_msu_share_point. E.g. WindowsClient\Windows11\23H2
windows_update_msu_path: ''
# The use name and password for accessing above Windows shared folder.
# windows_nfs_username: "CHANGEME"
# windows_nfs_pwd: "CHANGEME"

#####################################
# GOS related parameters
Expand Down
3 changes: 3 additions & 0 deletions windows/utils/add_windows_host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
when:
- win_ansible_connection is defined
- win_ansible_connection | lower == 'winrm'
no_log: "{{ hide_secrets | default(false) }}"

- name: "Add specified Windows IP to the hosts"
add_host:
Expand All @@ -47,6 +48,8 @@
when: >
(win_ansible_connection is undefined) or
(win_ansible_connection | lower == 'psrp')
no_log: "{{ hide_secrets | default(false) }}"

- ansible.builtin.debug: var=add_host_result
when: enable_debug is defined and enable_debug
no_log: "{{ hide_secrets | default(false) }}"
9 changes: 8 additions & 1 deletion windows/windows_update_install/install_msu_file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- name: "Set the .msu file installation related parameters"
ansible.builtin.set_fact:
msu_kb_number: "{{ msu_file_name | regex_search('(?i)KB\\d+') | upper }}"
msu_file_dest_path: "{{ msu_dir_path }}\\{{msu_file_name }}"
msu_file_dest_path: "{{ msu_dir_path }}\\{{ msu_file_name }}"
msu_install_timeout: 7200
msu_become_user: "{{ 'SYSTEM' if guest_os_ansible_architecture == '32-bit' else 'Administrator' }}"

Expand All @@ -27,6 +27,13 @@
environment:
ANSIBLE_WIN_ASYNC_STARTUP_TIMEOUT: 10

- name: "Check if the .msu file installation task started"
ansible.builtin.assert:
that:
- install_msu_result is defined
- install_msu_result.ansible_job_id is defined
fail_msg: "The result of above .msu file installation task executed in guest OS is not returned."

- name: "Check if the .msu file is installed before restart"
ansible.windows.win_shell: "Get-HotFix | Where-Object HotFixID -eq {{ msu_kb_number }}"
register: win_get_hotfix_result
Expand Down
12 changes: 11 additions & 1 deletion windows/windows_update_install/prepare_msu_file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@
win_powershell_cmd: "mkdir {{ msu_dir_path }}"
when: not win_is_folder_result

- name: "Set mount command for accessing the shared folder"
ansible.builtin.set_fact:
win_nfs_mount_cmd: |-
{%- if windows_nfs_username is defined and windows_nfs_username and
windows_nfs_pwd is defined and windows_nfs_pwd -%}
{{ 'net use ' ~ drive_letter_new ~ ': ' ~ windows_msu_share_point ~ ' ' ~ windows_nfs_pwd ~ ' /user:' ~ windows_nfs_username }}
{%- else -%}
{{ 'net use ' ~ drive_letter_new ~ ': ' ~ windows_msu_share_point }}
{%- endif -%}
- name: "Copy the .msu file to local disk of guest OS"
include_tasks: ../utils/win_execute_cmd.yml
vars:
win_powershell_cmd: >-
net use {{ drive_letter_new }}: {{ windows_msu_share_point }} {{ windows_nfs_pwd }} /user:{{ windows_nfs_username }};
{{ win_nfs_mount_cmd }};
Copy-Item -Path {{ msu_file_src_path }} -Include *.msu -Destination {{ msu_dir_path }} -ErrorAction Stop;
net use {{ drive_letter_new }}: /delete
Expand Down
9 changes: 9 additions & 0 deletions windows/windows_update_install/windows_update_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
vars:
create_current_test_folder: true

- name: "Skip test case"
include_tasks: ../../common/skip_test_case.yml
vars:
skip_msg: >-
Skip test case due to windows_update_msu_path is not provided
and no need to test the .msu file installation
skip_reason: "Skipped"
when: windows_update_msu_path is undefined or not windows_update_msu_path

- name: "Prepare the .msu file"
include_tasks: prepare_msu_file.yml

Expand Down

0 comments on commit ba0e085

Please sign in to comment.