From 3cf73e893822386c6656a42e0a0a8108e0b7da39 Mon Sep 17 00:00:00 2001 From: "Qi (Keira) Zhang" Date: Tue, 11 Apr 2023 14:32:16 +0800 Subject: [PATCH] Support VMware Photon OS 5.0 automation tests (#452) Signed-off-by: Qi Zhang --- README.md | 2 +- common/set_current_testcase_facts.yml | 4 +- .../deploy_vm/create_unattend_install_iso.yml | 1 + .../get_install_uninstall_cmd.yml | 6 +-- linux/open_vm_tools/install_ovt.yml | 42 ++++++++++--------- linux/utils/add_official_online_repo.yml | 13 +++++- linux/utils/create_seed_iso.yml | 16 +++---- 7 files changed, 49 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index a9c0745db..582ae00e7 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ This project supports below scenarios for end-to-end guest operating system vali | AlmaLinux 8.x, 9.x | :heavy_check_mark: | | :heavy_check_mark: | | SUSE Linux Enterprise 15 SP3 and later | :heavy_check_mark: | | :heavy_check_mark: | | SUSE Linux Enterprise 12 SP5, 15 SP0/SP1/SP2 | | | :heavy_check_mark: | -| VMware Photon OS 3.x, 4.x | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | +| VMware Photon OS 3.0, 4.0, 5.0 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | Ubuntu 18.04 and later live-server | :heavy_check_mark: | | :heavy_check_mark: | | Ubuntu 20.04 and later cloud image | | :heavy_check_mark: | :heavy_check_mark: | | Ubuntu 18.04 desktop | | | :heavy_check_mark: | diff --git a/common/set_current_testcase_facts.yml b/common/set_current_testcase_facts.yml index e439bf80e..ea6388166 100644 --- a/common/set_current_testcase_facts.yml +++ b/common/set_current_testcase_facts.yml @@ -12,8 +12,8 @@ # so that test cases log folders are sorted - name: "Set current test case index and name" ansible.builtin.set_fact: - current_testcase_index: "{{ '{:<}'.format(((current_testcase_index | default(0) | int + 1) | string). - rjust(gosv_testcases_count | string | length, '0')) }}" + current_testcase_index: "{{ '{:<}'.format(((current_testcase_index | default(0) | int + 1) | + string).rjust(gosv_testcases_count | string | length, '0')) }}" current_testcase_name: "{{ ansible_play_name }}" - name: "Set the log folder path for current test case on local machine" diff --git a/linux/deploy_vm/create_unattend_install_iso.yml b/linux/deploy_vm/create_unattend_install_iso.yml index ac6d250f5..8822dbeb6 100644 --- a/linux/deploy_vm/create_unattend_install_iso.yml +++ b/linux/deploy_vm/create_unattend_install_iso.yml @@ -154,6 +154,7 @@ ansible.builtin.copy: src: "{{ new_unattend_install_conf }}" dest: "{{ current_test_log_folder }}/{{ new_unattend_install_conf | basename }}" + when: unattend_install_conf is not match('Ubuntu/Server/') - name: "Remove cache folder {{ unattend_iso_cache }}" ansible.builtin.file: diff --git a/linux/open_vm_tools/get_install_uninstall_cmd.yml b/linux/open_vm_tools/get_install_uninstall_cmd.yml index cc121aa83..8fadf003e 100644 --- a/linux/open_vm_tools/get_install_uninstall_cmd.yml +++ b/linux/open_vm_tools/get_install_uninstall_cmd.yml @@ -12,9 +12,9 @@ - name: "Set OS commands for installing or uninstalling packages on {{ guest_os_ansible_distribution }}" ansible.builtin.set_fact: - package_install_cmd: "tdnf --enablerepo=photon --enablerepo=photon-updates -y install" - package_uninstall_cmd: "tdnf --enablerepo=photon --enablerepo=photon-updates -y remove" - check_update_cmd: "tdnf --enablerepo=photon --enablerepo=photon-updates makecache" + package_install_cmd: "tdnf install -y" + package_uninstall_cmd: "tdnf remove -y" + check_update_cmd: "tdnf makecache" clean_cache_cmd: "tdnf clean all" when: guest_os_ansible_distribution == "VMware Photon OS" diff --git a/linux/open_vm_tools/install_ovt.yml b/linux/open_vm_tools/install_ovt.yml index 448d337fb..1a15ac684 100644 --- a/linux/open_vm_tools/install_ovt.yml +++ b/linux/open_vm_tools/install_ovt.yml @@ -5,31 +5,33 @@ # Parameters # ovt_packages: open-vm-tools package names -# Update online repo for CentOS archived version and stream version -- include_tasks: ../utils/add_official_online_repo.yml - when: guest_os_ansible_distribution == 'CentOS' +- name: "Add online package repositories for {{ guest_os_ansible_distribution }}" + include_tasks: ../utils/add_official_online_repo.yml + when: guest_os_ansible_distribution in ['CentOS', 'VMware Photon OS'] -- block: - # Add a local repo from ISO image for RHEL/SLES/SLED - - include_tasks: ../utils/add_local_dvd_repo.yml +- name: "Add package repositories for {{ guest_os_ansible_distribution }}" + block: + - name: "Add a local package repository from ISO image for {{ guest_os_ansible_distribution }}" + include_tasks: ../utils/add_local_dvd_repo.yml when: guest_os_ansible_distribution in ['SLES', 'SLED', 'RedHat'] - # Add online repo for OracleLinux, Ubuntu, Debian and Photon - - include_tasks: ../utils/add_official_online_repo.yml - when: guest_os_ansible_distribution in ['OracleLinux', 'Ubuntu', 'Debian', 'VMware Photon OS'] + - name: "Add online package repositories for {{ guest_os_ansible_distribution }}" + include_tasks: ../utils/add_official_online_repo.yml + when: guest_os_ansible_distribution in ['OracleLinux', 'Ubuntu', 'Debian'] when: linux_ovt_repo_url is undefined or not linux_ovt_repo_url -- include_tasks: ../utils/add_extra_online_repo.yml +- name: "Add an extra open-vm-tools repository from URL" + include_tasks: ../utils/add_extra_online_repo.yml vars: extra_repo_name: "open-vm-tools-repo" extra_repo_baseurl: "{{ linux_ovt_repo_url }}" when: linux_ovt_repo_url is defined and linux_ovt_repo_url -# Get OS commands to install open-vm-tools -- include_tasks: get_install_uninstall_cmd.yml +- name: "Get OS commands to install open-vm-tools" + include_tasks: get_install_uninstall_cmd.yml -# Update package metadata -- include_tasks: ../utils/repo_update.yml +- name: "Update package metadata" + include_tasks: ../utils/repo_update.yml # Install open-vm-tools packages - name: "Install packages {{ ovt_packages }}" @@ -52,14 +54,14 @@ - ovt_install_result.rc | int == 0 fail_msg: "Failed to install open-vm-tools by executing command: {{ ' '.join(ovt_install_result.cmd) }}." -# Eject CDROM /dev/sr0 from guest -- include_tasks: ../utils/eject_cdrom_in_guest.yml +- name: "Eject CDROM device from guest OS" + include_tasks: ../utils/eject_cdrom_in_guest.yml when: - linux_ovt_repo_url is undefined or not linux_ovt_repo_url - guest_os_ansible_distribution in ['SLES', 'SLED', 'RedHat'] -# Reboot and Wait for tools running -- include_tasks: ../utils/reboot.yml +- name: "Reboot guest OS" + include_tasks: ../utils/reboot.yml -# Get VMware Tools version and build -- include_tasks: ../utils/get_guest_ovt_version_build.yml +- name: "Get VMware Tools version and build" + include_tasks: ../utils/get_guest_ovt_version_build.yml diff --git a/linux/utils/add_official_online_repo.yml b/linux/utils/add_official_online_repo.yml index 8d211b060..4ff44a441 100644 --- a/linux/utils/add_official_online_repo.yml +++ b/linux/utils/add_official_online_repo.yml @@ -183,12 +183,12 @@ block: - name: "Set the fact of VMware Photon OS {{ guest_os_ansible_distribution_major_ver }} online repositories" ansible.builtin.set_fact: - photon_online_repos: ["photon", "photon-updates", "photon-extras"] + photon_online_repos: ["photon", "photon-updates"] when: guest_os_ansible_distribution_major_ver | int < 4 - name: "Set the fact of VMware Photon OS {{ guest_os_ansible_distribution_major_ver }} online repositories" ansible.builtin.set_fact: - photon_online_repos: ["photon", "photon-release", "photon-updates", "photon-extras"] + photon_online_repos: ["photon-release", "photon-updates"] when: guest_os_ansible_distribution_major_ver | int >= 4 - name: "Enable VMware Photon OS online repositories" @@ -200,6 +200,15 @@ option_value: 1 with_items: "{{ photon_online_repos }}" + - name: "Disable VMware Photon OS online repository - photon.repo" + include_tasks: ../../common/update_ini_style_file.yml + vars: + file_path: "/etc/yum.repos.d/photon.repo" + section_name: "photon" + option_name: "enabled" + option_value: 0 + when: guest_os_ansible_distribution_major_ver | int == 5 + - name: "Update baseurl to repositories on https://packages.vmware.com/photon" block: - name: "Update repo's baseurl" diff --git a/linux/utils/create_seed_iso.yml b/linux/utils/create_seed_iso.yml index 4b3ad8d81..2fb88d1eb 100644 --- a/linux/utils/create_seed_iso.yml +++ b/linux/utils/create_seed_iso.yml @@ -45,13 +45,15 @@ path: "{{ meta_data_path }}" line: "local-hostname: {{ local_hostname }}" -- name: "Dump cloud-init user data" - ansible.builtin.debug: - msg: "{{ lookup('file', user_data_path).split('\n') }}" - -- name: "Dump cloud-init meta data" - ansible.builtin.debug: - msg: "{{ lookup('file', meta_data_path).split('\n') }}" +- name: "Collect cloud-init meta data and user data to log folder" + ansible.builtin.copy: + src: "{{ cloud_init_data }}" + dest: "{{ current_test_log_folder }}/{{ cloud_init_data | basename }}" + with_items: + - "{{ meta_data_path }}" + - "{{ user_data_path }}" + loop_control: + loop_var: cloud_init_data - name: "Create seed.iso as cloud-init local datasource" include_tasks: ../../common/create_iso.yml