Skip to content

Commit

Permalink
Support VMware Photon OS 5.0 automation tests (#452)
Browse files Browse the repository at this point in the history
Signed-off-by: Qi Zhang <qiz@vmware.com>
  • Loading branch information
keirazhang authored Apr 11, 2023
1 parent 6e3b605 commit 3cf73e8
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions common/set_current_testcase_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions linux/deploy_vm/create_unattend_install_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions linux/open_vm_tools/get_install_uninstall_cmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
42 changes: 22 additions & 20 deletions linux/open_vm_tools/install_ovt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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
13 changes: 11 additions & 2 deletions linux/utils/add_official_online_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
16 changes: 9 additions & 7 deletions linux/utils/create_seed_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3cf73e8

Please sign in to comment.