From 6f51081578a7967c79a785de02c4a14af2cb896d Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Tue, 13 Jun 2023 16:36:20 +0800 Subject: [PATCH 01/10] Fix autoinstall failure for Debian 12 Signed-off-by: Qi Zhang --- autoinstall/Debian/10/preseed.cfg | 28 ++++- linux/deploy_vm/deploy_vm_from_iso.yml | 149 ++++++++++++++----------- 2 files changed, 111 insertions(+), 66 deletions(-) diff --git a/autoinstall/Debian/10/preseed.cfg b/autoinstall/Debian/10/preseed.cfg index 565dc887f..7134c189f 100644 --- a/autoinstall/Debian/10/preseed.cfg +++ b/autoinstall/Debian/10/preseed.cfg @@ -163,8 +163,10 @@ tasksel tasksel/first multiselect standard, desktop tasksel tasksel/desktop multiselect gnome # Individual additional packages to install -# There is no open-vm-tools-desktop and cloud-init in CDROM -d-i pkgsel/include string build-essential vim locales open-vm-tools openssh-server sg3-utils +d-i pkgsel/include string build-essential vim locales openssh-server sg3-utils +# There is no open-vm-tools-desktop and cloud-init in CDROM of Debian 10 & 11 +# There is no open-vm-tools in CDROM of Debian 12 +# These packages will be installed in late-command # Policy for applying updates. May be "none" (no automatic updates), # "unattended-upgrades" (install security updates automatically), or @@ -221,12 +223,34 @@ d-i finish-install/reboot_in_progress note # packages and run commands in the target system. d-i preseed/late_command string \ {% if new_user is defined and new_user != 'root' %} + echo "Add new user {{ new_user }}" >/target/dev/ttyS0; \ echo '{{ new_user }} ALL=(ALL) NOPASSWD:ALL' >/target/etc/sudoers.d/{{ new_user }}; \ + echo "Add SSH authorized keys for user {{ new_user }}" >/target/dev/ttyS0; \ mkdir -p -m 700 /target/home/{{ new_user }}/.ssh; \ echo "{{ ssh_public_key }}" > /target/home/{{ new_user }}/.ssh/authorized_keys; \ {% endif %} mkdir -p -m 700 /target/root/.ssh; \ echo "{{ ssh_public_key }}" > /target/root/.ssh/authorized_keys; \ + if [ -f "/target/etc/os-release" ]; then \ + echo "Add offical repo ..." > /target/dev/ttyS0; \ + version=$(cat /target/etc/os-release | grep VERSION_ID | cut -d '=' -f 2 | tr -d '"'); \ + codename=$(cat /target/etc/os-release | grep VERSION_CODENAME | cut -d '=' -f 2 | tr -d '"'); \ + echo "Debian release version is $version, codename is $codename" > /target/dev/ttyS0; \ + if [ $version -lt 12 ]; then \ + echo "Install open-vm-tools from CDROM" > /target/dev/ttyS0; \ + chroot /traget apt install -y open-vm-tools >/dev/ttyS0; \ + fi; \ + echo "deb http://deb.debian.org/debian/ $codename main contrib" >> /target/etc/apt/sources.list; \ + echo "Display APT source list" >/target/dev/ttyS0; \ + cat /target/etc/apt/sources.list; \ + chroot /target apt update >/dev/ttyS0; \ + if [ $version -ge 12 ]; then \ + echo "Install open-vm-tools from online repo" > /target/dev/ttyS0; \ + chroot /target apt install -y open-vm-tools >/dev/ttyS0; \ + fi;\ + chroot /target apt install -y open-vm-tools-desktop cloud-init rdma-core rdmacm-utils ibverbs-utils; \ + in-target apt install -y rdma-core rdmacm-utils ibverbs-utils >/target/dev/ttyS0; \ + fi; >/dev/ttyS0; \ in-target chown --recursive root:root /root/.ssh; \ in-target chmod 0644 /root/.ssh/authorized_keys; \ in-target sed -i 's/#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config; \ diff --git a/linux/deploy_vm/deploy_vm_from_iso.yml b/linux/deploy_vm/deploy_vm_from_iso.yml index 40599d10c..e080a36de 100644 --- a/linux/deploy_vm/deploy_vm_from_iso.yml +++ b/linux/deploy_vm/deploy_vm_from_iso.yml @@ -28,12 +28,15 @@ - name: "Test case block" block: - - include_tasks: ../../common/get_iso_file_list.yml + - name: "Get OS installation ISO file list" + include_tasks: ../../common/get_iso_file_list.yml - - include_tasks: ubuntu/prepare_ubuntu_iso_install.yml + - name: "Prepare for Ubuntu installation" + include_tasks: ubuntu/prepare_ubuntu_iso_install.yml when: "'ubuntu' in guest_id" - - block: + - name: "Set default unattend install conf file" + block: - name: "Set default unattend install conf file for VMware Photon OS" ansible.builtin.set_fact: unattend_install_conf: "Photon/ks.cfg" @@ -42,76 +45,87 @@ - name: "Set default unattend install conf file for Debian" ansible.builtin.set_fact: unattend_install_conf: "Debian/10/preseed.cfg" - when: "'debian10' in guest_id or 'debian11' in guest_id" - + when: guest_id is match("debian1\\d+") + - name: "Set default unattend install conf file for FreeBSD" ansible.builtin.set_fact: unattend_install_conf: "FreeBSD/installerconfig" when: "'freebsd' in guest_id" when: unattend_install_conf is undefined or not unattend_install_conf - - ansible.builtin.debug: + - name: "warning: unattend_install_conf is undefined" + ansible.builtin.debug: msg: "unattend_install_conf is not defined or set to a file path, will not generate unattend iso file" when: unattend_install_conf is undefined or not unattend_install_conf - # Generate unattend install iso file - - include_tasks: create_unattend_install_iso.yml + - name: "Generate unattend install iso file" + include_tasks: create_unattend_install_iso.yml when: unattend_install_conf is defined and unattend_install_conf - # Compose VM CDROMs to mount OS install ISO files - - include_tasks: ../../common/compose_vm_cdroms.yml - # Create a new VM - - include_tasks: ../../common/vm_create.yml + - name: "Compose VM CDROMs to mount OS install ISO files" + include_tasks: ../../common/compose_vm_cdroms.yml + + - name: "Create a new VM with {{ boot_disk_controller }} disk" + include_tasks: ../../common/vm_create.yml when: boot_disk_controller != 'ide' - - include_tasks: ../../common/vm_create_with_ide_disk.yml + + - name: "Create a new VM with {{ boot_disk_controller }} disk" + include_tasks: ../../common/vm_create_with_ide_disk.yml when: boot_disk_controller == 'ide' - - include_tasks: ../../common/vm_get_vm_info.yml + + - name: "Get VM info" + include_tasks: ../../common/vm_get_vm_info.yml + - name: "Set fact of vm_exists to True" ansible.builtin.set_fact: vm_exists: true - # Add a serial port to monitor autoinstall process - - include_tasks: ../../common/vm_add_serial_port.yml + - name: "Add a serial port to monitor autoinstall process" + include_tasks: ../../common/vm_add_serial_port.yml - - block: - - include_tasks: ../../common/vm_get_video_card.yml + - name: "Set video memory size" + block: + - name: "Get VM's video card info" + include_tasks: ../../common/vm_get_video_card.yml - - name: Get VM default video memory size + - name: "Get VM default video memory size" ansible.builtin.set_fact: vm_default_video_memory_mb: "{{ (vm_video_cart_facts.instance.video_memory | int) / 1024 }}" - # Increase VM's video card memory to 8 MB in case desktop can't be loaded - - include_tasks: ../../common/vm_set_video_card.yml + - name: "Increase VM's video card memory to 8 MB in case desktop can't be loaded" + include_tasks: ../../common/vm_set_video_card.yml vars: video_memory_mb: 8 when: vm_default_video_memory_mb | int < 8 when: install_guest_with_desktop - # Enable secureboot - - include_tasks: ../../common/vm_set_boot_options.yml + - name: "Enable secure boot on VM" + include_tasks: ../../common/vm_set_boot_options.yml vars: secure_boot_enabled_set: true when: - firmware is defined and firmware | lower == 'efi' - secureboot_enabled is defined and secureboot_enabled - # Add virtual TPM device - - include_tasks: ../../common/vm_add_vtpm_device.yml + - name: "Add virtual TPM device" + include_tasks: ../../common/vm_add_vtpm_device.yml vars: vc_cert_path: "{{ current_test_log_folder }}" when: - firmware is defined and firmware | lower == 'efi' - virtual_tpm is defined and virtual_tpm | bool - - include_tasks: ../../common/vm_set_power_state.yml + - name: "Power on VM" + include_tasks: ../../common/vm_set_power_state.yml vars: vm_power_state_set: 'powered-on' - - name: Sleep 5 seconds to wait boot screen display + + - name: "Sleep 5 seconds to wait boot screen display" ansible.builtin.pause: seconds: 5 - # Check Image APPROVED in vmware.log when VM secureboot is enabled - - include_tasks: ../../common/vm_wait_log_msg.yml + - name: "Check Image APPROVED in vmware.log when VM secure boot is enabled" + include_tasks: ../../common/vm_wait_log_msg.yml vars: vm_wait_log_name: "vmware.log" vm_wait_log_msg: "SECUREBOOT: Image APPROVED" @@ -122,12 +136,14 @@ - firmware is defined and firmware | lower == 'efi' - secureboot_enabled is defined and secureboot_enabled - - include_tasks: ubuntu/ubuntu_install_os.yml + - name: "Install Ubuntu OS" + include_tasks: ubuntu/ubuntu_install_os.yml when: "'ubuntu' in guest_id" - # For SLES, OS installation with BIOS firmware, sendkey to boot + # For SLES, OS installation with BIOS firmware, send key to boot # screen to start new installation instead of booting from local - - include_tasks: ../../common/vm_guest_send_key.yml + - name: "Select boot menu for SLES/SLED" + include_tasks: ../../common/vm_guest_send_key.yml vars: keys_send: - DOWNARROW @@ -137,10 +153,11 @@ - ('SLE' in unattend_install_conf or 'openSUSE' in unattend_install_conf) - firmware is defined and firmware|lower == "bios" - # For RHEL, CentOS, RockyLinux, OracleLinux, sendkey to boot screen to not do + # For RHEL, CentOS, RockyLinux, OracleLinux, send key to boot screen to not do # disk check and start installation directly. RockyLinux is using Other 4.x or # later Linux (64-bit) as guest OS type. - - include_tasks: ../../common/vm_guest_send_key.yml + - name: "Select boot menu for RHEL or Fedora family OS" + include_tasks: ../../common/vm_guest_send_key.yml vars: keys_send: - UPARROW @@ -151,8 +168,9 @@ ('CentOS' in unattend_install_conf) or ('Fedora' in unattend_install_conf)) - # For UnionTech OS Server, sendkey to boot screen - - include_tasks: ../../common/vm_guest_send_key.yml + # For UnionTech OS, send key to boot screen + - name: "Select boot menu for UnionTech OS" + include_tasks: ../../common/vm_guest_send_key.yml vars: keys_send: - ENTER @@ -170,8 +188,8 @@ - unattend_install_conf is defined - unattend_install_conf is match('Ubuntu/Desktop/Ubiquity') - # Wait autoinstall complete message appear in serial port output file - - include_tasks: ../../common/vm_wait_log_msg.yml + - name: "Wait autoinstall complete message appear in serial port output file" + include_tasks: ../../common/vm_wait_log_msg.yml vars: vm_wait_log_name: "{{ vm_serial_port_output_file | basename }}" vm_wait_log_msg: "{{ autoinstall_complete_msg }}" @@ -182,25 +200,22 @@ ansible.builtin.pause: seconds: 60 - # For VMware Photon OS and Ubuntu - - include_tasks: ../../common/vm_wait_guest_fullname.yml + - name: "Wait for guest full name is collected" + include_tasks: ../../common/vm_wait_guest_fullname.yml when: - unattend_install_conf is defined - - unattend_install_conf is match('Photon') or unattend_install_conf is match('Ubuntu') - - - name: "Get VM's primary network adapter MAC address after poweron VM" - include_tasks: ../../common/vm_wait_primary_nic_mac.yml - when: vm_primary_nic_mac is undefined or not vm_primary_nic_mac + - unattend_install_conf | lower is not match('.*(minimal|server_without_gui).*') - # Get guest IP - - include_tasks: ../../common/update_inventory.yml + - name: "Get VM guest IPv4 address and add to in-memory inventory" + include_tasks: ../../common/update_inventory.yml vars: update_inventory_timeout: 600 - # Retrieve guest system info - - include_tasks: ../utils/get_linux_system_info.yml + - name: "Get Linux system info" + include_tasks: ../utils/get_linux_system_info.yml - - block: + - name: "Wait for guest OS service is ready" + block: # For SLE, RHEL8/CentOS8/OracleLinux8 with desktop: display-manager # service running at the end of installation to wait user login. # Otherwise, systemd-logind service running at the end of installaiton @@ -212,7 +227,8 @@ {%- else -%}systemd-logind {%- endif -%} - - include_tasks: ../utils/wait_for_service_status.yml + - name: "Wait for service {{ wait_service_name }} is running" + include_tasks: ../utils/wait_for_service_status.yml vars: - service_name: "{{ wait_service_name }}" - wait_service_status: "running" @@ -220,8 +236,8 @@ - guest_os_with_gui is defined - guest_os_family in ["RedHat", "Suse"] or guest_os_ansible_distribution == "Ubuntu" - # Eject unattend/seed iso and delete it from datastore - - include_tasks: eject_del_unattend_install_iso.yml + - name: "Eject unattend/seed iso and delete it from datastore" + include_tasks: eject_del_unattend_install_iso.yml when: - transferred_unattend_iso is defined - transferred_unattend_iso @@ -255,8 +271,8 @@ - guest_os_ansible_distribution_ver == "9.0" - "'uek' in guest_os_ansible_kernel" - # Remove serial port - - include_tasks: ../utils/shutdown.yml + - name: "Shutdown guest OS" + include_tasks: ../utils/shutdown.yml - name: "Change CD/DVD to client device and set disk as first boot device for Ubuntu" block: @@ -274,7 +290,7 @@ boot_order_list: - disk when: guest_os_ansible_distribution == "Ubuntu" - + - name: "Download serial output file before removing serial port" include_tasks: ../../common/esxi_download_datastore_file.yml vars: @@ -282,31 +298,35 @@ src_file_path: "{{ vm_dir_name }}/{{ vm_serial_port_output_file | basename }}" dest_file_path: "{{ current_test_log_folder }}/{{ vm_serial_port_output_file | basename }}" download_file_fail_ignore: true - when: + when: - vm_dir_name is defined - vm_dir_name - vm_serial_port_output_file is defined - vm_serial_port_output_file - - include_tasks: ../../common/vm_remove_serial_port.yml + - name: "Remove serial port" + include_tasks: ../../common/vm_remove_serial_port.yml - - ansible.builtin.fail: + - name: "Failed to remove serial port" + ansible.builtin.fail: msg: "Failed to remove serial port from VM" when: > remove_serial_port is undefined or remove_serial_port.changed is undefined or not remove_serial_port.changed - - include_tasks: ../../common/vm_set_power_state.yml + - name: "Power on VM" + include_tasks: ../../common/vm_set_power_state.yml vars: vm_power_state_set: 'powered-on' - name: "Check Oracle Linux 9.0 kernel UEK R7 is upgraded" block: - - include_tasks: ../../common/update_inventory.yml + - name: "Update VM guest IPv4 address in in-memory inventory" + include_tasks: ../../common/update_inventory.yml - # Refresh guest system info - - include_tasks: ../utils/get_linux_system_info.yml + - name: "Refresh Linux system info" + include_tasks: ../utils/get_linux_system_info.yml - name: "Get Oracle Linux 9.0 UEK R7 version after upgrading" ansible.builtin.set_fact: @@ -325,7 +345,8 @@ - ol9_uekr7_is_upgraded rescue: - - include_tasks: ../../common/test_rescue.yml + - name: "Test case failure" + include_tasks: ../../common/test_rescue.yml vars: exit_testing_when_fail: true always: From 4249f22ed7f80e81af5e1cfdc496e4aba6e741ba Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Tue, 13 Jun 2023 20:09:12 +0800 Subject: [PATCH 02/10] Get Debian minor version from ansible_distribution_minor_version Signed-off-by: Qi Zhang --- common/get_guest_system_info.yml | 7 ++++++- linux/utils/get_linux_system_info.yml | 14 -------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/common/get_guest_system_info.yml b/common/get_guest_system_info.yml index 50d99ee25..6d04810d2 100644 --- a/common/get_guest_system_info.yml +++ b/common/get_guest_system_info.yml @@ -3,6 +3,8 @@ --- # Get guest system info when it's not defined before # Note: +# For Debian 10.x and 11.x, its 'ansible_distribution_version' only shows major version, +# minor version can be retrieved from 'ansible_distribution_minor_version'. # For FreeBSD 11.4, there is no 'ansible_distribution_major_version' in guest_system_info, # use version info in 'ansible_distribution_release'. # For Windows guest, there is no 'ansible_distribution_release' in guest_system_info, @@ -32,7 +34,10 @@ guest_os_ansible_architecture: "{{ guest_system_info.ansible_architecture | default('') }}" guest_os_ansible_distribution_ver: "{{ guest_system_info.ansible_distribution_version if guest_system_info.ansible_distribution != 'FreeBSD' else guest_system_info.ansible_kernel }}" guest_os_ansible_distribution_major_ver: "{{ guest_system_info.ansible_distribution_major_version if 'ansible_distribution_major_version' in guest_system_info else guest_system_info.ansible_distribution_release.split('-')[0].split('.')[0] }}" - guest_os_ansible_distribution_minor_ver: "{{ guest_system_info.ansible_distribution_version.split('.')[1] if guest_system_info.ansible_distribution_version.split('.') | length >= 2 else 0 }}" + guest_os_ansible_distribution_minor_ver: |- + {%- if guest_system_info.ansible_distribution_minor_version | default('') != '' -%}{{ guest_system_info.ansible_distribution_minor_version }} + {%- elif guest_system_info.ansible_distribution_version.split('.') | length >= 2 -%}{{ guest_system_info.ansible_distribution_version.split('.')[1] }} + {%- else -%}0{%- endif -%} guest_os_ansible_kernel: "{{ guest_system_info.ansible_kernel | default('') }}" guest_os_ansible_distribution_release: "{{ guest_system_info.ansible_distribution_release | default('') }}" guest_os_ansible_pkg_mgr: "{{ guest_system_info.ansible_pkg_mgr | default('') }}" diff --git a/linux/utils/get_linux_system_info.yml b/linux/utils/get_linux_system_info.yml index ee4fbc55b..eae4843e4 100644 --- a/linux/utils/get_linux_system_info.yml +++ b/linux/utils/get_linux_system_info.yml @@ -69,20 +69,6 @@ when: guest_os_redhat_release | regex_search("Red *Hat", ignorecase=True) when: not guest_os_ansible_distrib_is_correct -- name: "Get Debian OS version from /etc/debian_version" - block: - - name: "Get Debian version" - ansible.builtin.command: cat /etc/debian_version - register: debian_version_result - delegate_to: "{{ vm_guest_ip }}" - - - name: "Update guest OS distribution version" - ansible.builtin.set_fact: - guest_os_ansible_distribution_ver: "{{ debian_version_result.stdout }}" - guest_os_ansible_distribution_minor_ver: "{{ debian_version_result.stdout.split('.')[-1] }}" - when: debian_version_result.stdout is defined and debian_version_result.stdout - when: guest_os_ansible_distribution == "Debian" - - name: "Set OS family for {{ guest_os_ansible_distribution }} to RedHat" ansible.builtin.set_fact: guest_os_family: "RedHat" From d90de193d13c32007b6b4939b8b59b5487b8d28c Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Tue, 13 Jun 2023 20:11:24 +0800 Subject: [PATCH 03/10] Fix rescan lsilogic scsi issue Signed-off-by: Qi Zhang --- linux/vhba_hot_add_remove/wait_device_list_changed.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linux/vhba_hot_add_remove/wait_device_list_changed.yml b/linux/vhba_hot_add_remove/wait_device_list_changed.yml index 4342e5999..33b19b99f 100644 --- a/linux/vhba_hot_add_remove/wait_device_list_changed.yml +++ b/linux/vhba_hot_add_remove/wait_device_list_changed.yml @@ -46,7 +46,9 @@ when: - "'Flatcar' not in guest_os_ansible_distribution" - not (guest_os_ansible_distribution == "Ubuntu" and - guest_os_ansible_distribution_major_ver >= "22") + guest_os_ansible_distribution_major_ver | int >= 22) + - not (guest_os_ansible_distribution == "Debian" and + guest_os_ansible_distribution_major_ver | int >= 12) - guest_os_ansible_distribution != "Fedora" - name: "Rescan scsi devices in {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }}" @@ -83,7 +85,9 @@ when: > ('Flatcar' in guest_os_ansible_distribution or (guest_os_ansible_distribution == "Ubuntu" and - guest_os_ansible_distribution_major_ver >= "22") or + guest_os_ansible_distribution_major_ver | int >= 22) or + (guest_os_ansible_distribution == "Debian" and + guest_os_ansible_distribution_major_ver | int >= 12) or guest_os_ansible_distribution == "Fedora") when: new_disk_ctrl_type == 'lsilogic' @@ -164,5 +168,3 @@ - lsblk_result is defined - lsblk_result.unreachable is defined - lsblk_result.unreachable - - From 97c662a3f740c10128b8e779b85da3d69ce8725b Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Tue, 13 Jun 2023 20:55:36 +0800 Subject: [PATCH 04/10] Clean cloud-init logs and seed Signed-off-by: Qi Zhang --- linux/utils/enable_disable_cloudinit_cfg.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/utils/enable_disable_cloudinit_cfg.yml b/linux/utils/enable_disable_cloudinit_cfg.yml index 9f7bac41c..f0f438721 100644 --- a/linux/utils/enable_disable_cloudinit_cfg.yml +++ b/linux/utils/enable_disable_cloudinit_cfg.yml @@ -113,8 +113,8 @@ - cloudinit_gosc_enabled fail_msg: "Failed to enable cloud-init GOSC" - - name: "Clear cloud-init.log" - ansible.builtin.shell: "cat /dev/null >/var/log/cloud-init.log" + - name: "Clean cloud-init logs and seed" + ansible.builtin.shell: "/usr/bin/cloud-init clean --log --seed" delegate_to: "{{ vm_guest_ip }}" ignore_errors: true when: enable_cloudinit_gosc | bool From d82e03c2a5113ad41700ff9083af4dc828406099 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Wed, 14 Jun 2023 13:36:44 +0800 Subject: [PATCH 05/10] Disable initial setup Signed-off-by: Qi Zhang --- autoinstall/Debian/10/preseed.cfg | 35 ++++++++++++++++---------- linux/deploy_vm/deploy_vm_from_iso.yml | 3 ++- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/autoinstall/Debian/10/preseed.cfg b/autoinstall/Debian/10/preseed.cfg index 7134c189f..34c16b764 100644 --- a/autoinstall/Debian/10/preseed.cfg +++ b/autoinstall/Debian/10/preseed.cfg @@ -38,8 +38,8 @@ d-i netcfg/dhcp_failed note # Any hostname and domain names assigned from dhcp take precedence over # values set here. However, setting the values still prevents the questions # from being shown, even if values come from dhcp. -d-i netcfg/get_hostname string unassigned-hostname -d-i netcfg/get_domain string unassigned-domain +d-i netcfg/get_hostname string debian-hostname +d-i netcfg/get_domain string debian-domain # Disable that annoying WEP key dialog. d-i netcfg/wireless_wep string @@ -166,7 +166,7 @@ tasksel tasksel/desktop multiselect gnome d-i pkgsel/include string build-essential vim locales openssh-server sg3-utils # There is no open-vm-tools-desktop and cloud-init in CDROM of Debian 10 & 11 # There is no open-vm-tools in CDROM of Debian 12 -# These packages will be installed in late-command +# These packages will be installed in late_command # Policy for applying updates. May be "none" (no automatic updates), # "unattended-upgrades" (install security updates automatically), or @@ -232,25 +232,34 @@ d-i preseed/late_command string \ mkdir -p -m 700 /target/root/.ssh; \ echo "{{ ssh_public_key }}" > /target/root/.ssh/authorized_keys; \ if [ -f "/target/etc/os-release" ]; then \ - echo "Add offical repo ..." > /target/dev/ttyS0; \ version=$(cat /target/etc/os-release | grep VERSION_ID | cut -d '=' -f 2 | tr -d '"'); \ codename=$(cat /target/etc/os-release | grep VERSION_CODENAME | cut -d '=' -f 2 | tr -d '"'); \ echo "Debian release version is $version, codename is $codename" > /target/dev/ttyS0; \ - if [ $version -lt 12 ]; then \ + search_ovt=$(in-target apt search open-vm-tools 2>/dev/null); \ + printf "Search open-vm-tools packages in CDROM:\n$search_ovt" >/target/dev/ttyS0; \ + if [ "$search_ovt" != "" ]; then \ echo "Install open-vm-tools from CDROM" > /target/dev/ttyS0; \ - chroot /traget apt install -y open-vm-tools >/dev/ttyS0; \ + in-target apt install -y open-vm-tools >/dev/ttyS0; \ fi; \ + echo "Add offical online repo ..." > /target/dev/ttyS0; \ echo "deb http://deb.debian.org/debian/ $codename main contrib" >> /target/etc/apt/sources.list; \ echo "Display APT source list" >/target/dev/ttyS0; \ - cat /target/etc/apt/sources.list; \ - chroot /target apt update >/dev/ttyS0; \ - if [ $version -ge 12 ]; then \ + cat /target/etc/apt/sources.list >/target/dev/ttyS0; \ + echo "Update list of available packages" > /target/dev/ttyS0; \ + in-target apt update >/dev/ttyS0; \ + if [ "$search_ovt" == "" ]; then \ echo "Install open-vm-tools from online repo" > /target/dev/ttyS0; \ - chroot /target apt install -y open-vm-tools >/dev/ttyS0; \ + in-target apt install -y open-vm-tools >/dev/ttyS0; \ fi;\ - chroot /target apt install -y open-vm-tools-desktop cloud-init rdma-core rdmacm-utils ibverbs-utils; \ - in-target apt install -y rdma-core rdmacm-utils ibverbs-utils >/target/dev/ttyS0; \ - fi; >/dev/ttyS0; \ + echo "Install testing required packages from online repo" >/target/dev/ttyS0; \ + in-target apt install -y open-vm-tools-desktop cloud-init rdma-core rdmacm-utils ibverbs-utils \ + locales-all rdma-core rdmacm-utils ibverbs-utils >/dev/ttyS0; \ + fi; \ + gnome_initial_cfg="/etc/xdg/autostart/gnome-initial-setup-first-login.desktop"; \ + if [ -f "/target$gnome_initial_cfg" ]; then \ + echo "Disable GNOME initial setup at first login" >/target/dev/ttyS0; \ + in-target sed -i "s/^X-GNOME-HiddenUnderSystemd *=.*/X-GNOME-HiddenUnderSystemd=false/" $gnome_initial_cfg; \ + fi; \ in-target chown --recursive root:root /root/.ssh; \ in-target chmod 0644 /root/.ssh/authorized_keys; \ in-target sed -i 's/#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config; \ diff --git a/linux/deploy_vm/deploy_vm_from_iso.yml b/linux/deploy_vm/deploy_vm_from_iso.yml index e080a36de..e7193ebf7 100644 --- a/linux/deploy_vm/deploy_vm_from_iso.yml +++ b/linux/deploy_vm/deploy_vm_from_iso.yml @@ -234,7 +234,8 @@ - wait_service_status: "running" when: - guest_os_with_gui is defined - - guest_os_family in ["RedHat", "Suse"] or guest_os_ansible_distribution == "Ubuntu" + - (guest_os_family in ["RedHat", "Suse"] or + guest_os_ansible_distribution in ["Ubuntu", "Debian"]) - name: "Eject unattend/seed iso and delete it from datastore" include_tasks: eject_del_unattend_install_iso.yml From 3fa65ba4670d9b32b84412813918f59c0620d65f Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Wed, 14 Jun 2023 15:11:58 +0800 Subject: [PATCH 06/10] Remove changes about cloud-init Signed-off-by: Qi Zhang --- linux/utils/enable_disable_cloudinit_cfg.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/utils/enable_disable_cloudinit_cfg.yml b/linux/utils/enable_disable_cloudinit_cfg.yml index f0f438721..9f7bac41c 100644 --- a/linux/utils/enable_disable_cloudinit_cfg.yml +++ b/linux/utils/enable_disable_cloudinit_cfg.yml @@ -113,8 +113,8 @@ - cloudinit_gosc_enabled fail_msg: "Failed to enable cloud-init GOSC" - - name: "Clean cloud-init logs and seed" - ansible.builtin.shell: "/usr/bin/cloud-init clean --log --seed" + - name: "Clear cloud-init.log" + ansible.builtin.shell: "cat /dev/null >/var/log/cloud-init.log" delegate_to: "{{ vm_guest_ip }}" ignore_errors: true when: enable_cloudinit_gosc | bool From c19578bb9df39b549b3a3703337de8bac463b2be Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Wed, 14 Jun 2023 18:23:53 +0800 Subject: [PATCH 07/10] Update preseed late command Signed-off-by: Qi Zhang --- autoinstall/Debian/10/preseed.cfg | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/autoinstall/Debian/10/preseed.cfg b/autoinstall/Debian/10/preseed.cfg index 34c16b764..f1b983369 100644 --- a/autoinstall/Debian/10/preseed.cfg +++ b/autoinstall/Debian/10/preseed.cfg @@ -66,7 +66,7 @@ d-i passwd/user-password-crypted password {{ vm_password_hash }} # The user account will be added to some standard initial groups. To # override that, use this. -d-i passwd/user-default-groups string root wheel +d-i passwd/user-default-groups string {{ new_user }} root wheel {% endif %} ### Clock and time zone setup @@ -228,9 +228,14 @@ d-i preseed/late_command string \ echo "Add SSH authorized keys for user {{ new_user }}" >/target/dev/ttyS0; \ mkdir -p -m 700 /target/home/{{ new_user }}/.ssh; \ echo "{{ ssh_public_key }}" > /target/home/{{ new_user }}/.ssh/authorized_keys; \ + chown --recursive {{ new_user }}:{{ new_user }} /target/home/{{ new_user }}/.ssh; \ + chmod 0644 /target/home/{{ new_user }}/.ssh/authorized_keys; \ {% endif %} + echo "Add SSH authorized keys for root" >/target/dev/ttyS0; \ mkdir -p -m 700 /target/root/.ssh; \ echo "{{ ssh_public_key }}" > /target/root/.ssh/authorized_keys; \ + chown --recursive root:root /target/root/.ssh; \ + chmod 0644 /target/root/.ssh/authorized_keys; \ if [ -f "/target/etc/os-release" ]; then \ version=$(cat /target/etc/os-release | grep VERSION_ID | cut -d '=' -f 2 | tr -d '"'); \ codename=$(cat /target/etc/os-release | grep VERSION_CODENAME | cut -d '=' -f 2 | tr -d '"'); \ @@ -252,16 +257,14 @@ d-i preseed/late_command string \ in-target apt install -y open-vm-tools >/dev/ttyS0; \ fi;\ echo "Install testing required packages from online repo" >/target/dev/ttyS0; \ - in-target apt install -y open-vm-tools-desktop cloud-init rdma-core rdmacm-utils ibverbs-utils \ + in-target apt install -y open-vm-tools-desktop cloud-init \ locales-all rdma-core rdmacm-utils ibverbs-utils >/dev/ttyS0; \ fi; \ - gnome_initial_cfg="/etc/xdg/autostart/gnome-initial-setup-first-login.desktop"; \ - if [ -f "/target$gnome_initial_cfg" ]; then \ + gnome_initial_cfg="/target/etc/xdg/autostart/gnome-initial-setup-first-login.desktop"; \ + if [ -f "$gnome_initial_cfg" ]; then \ echo "Disable GNOME initial setup at first login" >/target/dev/ttyS0; \ - in-target sed -i "s/^X-GNOME-HiddenUnderSystemd *=.*/X-GNOME-HiddenUnderSystemd=false/" $gnome_initial_cfg; \ + sed -i "s/^X-GNOME-HiddenUnderSystemd *=.*/X-GNOME-HiddenUnderSystemd=false/" $gnome_initial_cfg; \ fi; \ - in-target chown --recursive root:root /root/.ssh; \ - in-target chmod 0644 /root/.ssh/authorized_keys; \ in-target sed -i 's/#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config; \ in-target sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config; \ echo "{{ autoinstall_complete_msg }}" >/target/dev/ttyS0 From f9959bb239d3a5bc7d48f5aca4e7dfb806e52b71 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Thu, 15 Jun 2023 09:04:29 +0800 Subject: [PATCH 08/10] Update README Signed-off-by: Qi Zhang --- README.md | 2 +- autoinstall/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 98664d31e..b75c1c736 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ This project supports below scenarios for end-to-end guest operating system vali | Ubuntu 18.04 desktop | | | :heavy_check_mark: | | Ubuntu 20.04 and later | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | Flatcar 2592.0.0 and later | | :heavy_check_mark: | :heavy_check_mark: | -| Debian 10.10 and later, 11.x | :heavy_check_mark: | | :heavy_check_mark: | +| Debian 10.10 and later, 11.x, 12.x | :heavy_check_mark: | | :heavy_check_mark: | | Debian 9.x, 10.9 and earlier | | | :heavy_check_mark: | | Windows 10, 11 | :heavy_check_mark: | | :heavy_check_mark: | | Windows Server 2019, 2022 | :heavy_check_mark: | | :heavy_check_mark: | diff --git a/autoinstall/README.md b/autoinstall/README.md index 0a677c1f3..3712ce40b 100644 --- a/autoinstall/README.md +++ b/autoinstall/README.md @@ -4,7 +4,7 @@ 3. For RHEL or RHEL-like varieties 8.x or later unattend auto-install, please use files under RHEL/8. 4. For SLES 15 SP3 or later unattend auto-install, please use files under SLE/15/SP3/SLES or SLE/15/SP3/SLES_Minimal. 5. For SLED 15 SP3 unattend auto-install, please use SLE/15/SP3/SLED/autoinst.xml. -6. For SLED 15 SP4 unattend auto-install, please use SLE/15/SP4/SLED/autoinst.xml. +6. For SLED 15 SP4 or later unattend auto-install, please use SLE/15/SP4/SLED/autoinst.xml. 7. For Windows 10, or Windows 11 with TPM device unattend auto-install, please use files under Windows/win10. 8. For Windows 11 without TPM device unattend auto-install, please use files under Windows/win11 to bypass TPM check during installation. 9. For Windows Server LTSC unattend auto-install, please use files under Windows/win_server. @@ -13,7 +13,7 @@ 12. For Ubuntu Server 20.04 or later unattend auto-install, please use file Ubuntu/Server/user-data.j2. 13. For Ubuntu Desktop 20.04 ~ 22.10 unattend auto-install, please use file Ubuntu/Desktop/Ubiquity/ubuntu.seed. 14. For Ubuntu Destkop 23.04 or later unattend auto-install, please use file Ubuntu/Desktop/Subiquity/user-data.j2. -15. For Debian 10.1x or 11.x unattend auto-install, please use file Debian/10/preseed.cfg. +15. For Debian 10.1x, 11.x or later unattend auto-install, please use file Debian/10/preseed.cfg. 16. For UnionTech OS Server 20 1050a unattend auto-install, please use file UOS/Server/20/1050a/ks.cfg. 17. For UnionTech OS Server 20 1050e unattend auto-install, please use file UOS/Server/20/1050e/ks.cfg. 18. For Fedora Server 36 or later unattend auto-install, please use file Fedora/36/Server/ks.cfg. From 2aeda232811d68b7721e04ceefea445fb37474c2 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Tue, 20 Jun 2023 14:06:35 +0800 Subject: [PATCH 09/10] Skip cloud-init GOSC for Debian 12 Signed-off-by: Qi Zhang --- .../check_gosc_support_status.yml | 75 +++++++++++++------ 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/linux/guest_customization/check_gosc_support_status.yml b/linux/guest_customization/check_gosc_support_status.yml index 907b27321..520fed8e7 100644 --- a/linux/guest_customization/check_gosc_support_status.yml +++ b/linux/guest_customization/check_gosc_support_status.yml @@ -1,8 +1,8 @@ # Copyright 2021-2023 VMware, Inc. # SPDX-License-Identifier: BSD-2-Clause --- -# Skip GOSC testing if no vCenter or no open-vm-tools -- include_tasks: ../../common/skip_test_case.yml +- name: "Skip GOSC testing if no vCenter or no open-vm-tools" + include_tasks: ../../common/skip_test_case.yml vars: skip_msg: "Test case is blocked because test environment doesn't meet GOSC requirements" skip_reason: "Blocked" @@ -11,15 +11,16 @@ (not vcenter_is_defined) or (enable_cloudinit_gosc and not vmtools_is_ovt) -- block: - # Check GOSC support matrix +- name: "Check GOSC support status" + block: - name: "Initialize GOSC support status" ansible.builtin.set_fact: gosc_is_supported: true - - name: "Check perl GOSC support status for VMware Photon OS" + - name: "Check Perl GOSC support status for VMware Photon OS" block: - - include_tasks: ../utils/get_installed_package_info.yml + - name: "Get open-vm-tools package info" + include_tasks: ../utils/get_installed_package_info.yml vars: package_name: "open-vm-tools" @@ -31,7 +32,8 @@ - package_info.Release is defined - "'ph' not in package_info.Release | string" - - include_tasks: ../../common/skip_test_case.yml + - name: "Skip test case for not bundled open-vm-tools" + include_tasks: ../../common/skip_test_case.yml vars: skip_msg: "Perl GOSC is not applicable for {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} with not bundled open-vm-tools {{ vmtools_version }}." skip_reason: "Not Applicable" @@ -51,12 +53,32 @@ (guest_os_ansible_distribution in gos_not_support_gosc) or ('Flatcar' in guest_os_ansible_distribution) - - block: + - name: "Set cloud-init GOSC support status for {{ vm_guest_os_distribution }}" + block: + - name: "Set fact of cloud-init GOSC support status to False for {{ vm_guest_os_distribution }}" + ansible.builtin.set_fact: + gosc_is_supported: false + + - name: "Known issue - cloud-init GOSC failure for {{ vm_guest_os_distribution }}" + ansible.builtin.debug: + msg: >- + Cloud-init GOSC is blocked for {{ vm_guest_os_distribution }} due to cloud-int bugs + https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1776452 and + https://bugs.launchpad.net/cloud-init/+bug/1944946. + So skip cloud-init GOSC testing for {{ vm_guest_os_distribution }}. + when: + - enable_cloudinit_gosc | bool + - guest_os_ansible_distribution == "Debian" + - guest_os_ansible_distribution_major_ver | int == 12 + + - name: "Check Perl GOSC support status for {{ vm_guest_os_distribution }}" + block: - name: "Get GOSC support matrix" ansible.builtin.set_fact: gosc_support_matrix: "{{ lookup('file', 'gosc_support_matrix.yml') | from_yaml }}" - - block: + - name: "Check Perl GOSC support status for {{ vm_guest_os_distribution }} in support matrix" + block: - name: "Get {{ guest_os_ansible_distribution }} Perl GOSC testing supported OS versions" ansible.builtin.set_fact: gosc_matrix_os_versions: "{{ gosc_support_matrix[guest_os_ansible_distribution] | dict2items | map(attribute='key') }}" @@ -71,22 +93,23 @@ ((guest_os_ansible_distribution_ver | int) > (item | int)) with_items: "{{ gosc_matrix_os_versions }}" - - block: + - name: "Get Perl GOSC supported VC versions and builds" + block: - name: "Get {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} Perl GOSC supported VC versions and builds" ansible.builtin.set_fact: gosc_matrix_vc_list: "{{ gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vcenter'] | dict2items | map(attribute='key') }}" - - block: - - name: "Get {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} Perl GOSC support status on VC {{ vcenter_version }} build {{ vcenter_build }}" - ansible.builtin.set_fact: - gosc_is_supported: false + - name: "Get {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} Perl GOSC support status on VC {{ vcenter_version }} build {{ vcenter_build }}" + ansible.builtin.set_fact: + gosc_is_supported: false when: > (vcenter_version in gosc_matrix_vc_list and ((gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vcenter'][vcenter_version] == 'N/A') or (vcenter_build | int < gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vcenter'][vcenter_version] | int)) or (vcenter_version is version(gosc_matrix_vc_list[0], '<'))) - - block: + - name: "Get Perl GOSC supported open-vm-tools version for {{ vm_guest_os_distribution }}" + block: - name: "Get {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} Perl GOSC supported open-vm-tools version" ansible.builtin.set_fact: gosc_matrix_vmtools_version: "{{ gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vmtools'] }}" @@ -99,20 +122,28 @@ - gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vmtools'] is defined - gosc_support_matrix[guest_os_ansible_distribution][gosc_matrix_first_os_version]['vmtools'] when: gosc_matrix_first_os_version != 'None' - when: - - not enable_cloudinit_gosc | bool - - gosc_support_matrix[guest_os_ansible_distribution] is defined + when: gosc_support_matrix[guest_os_ansible_distribution] is defined when: + - not enable_cloudinit_gosc | bool - guest_os_ansible_distribution not in gos_not_support_gosc - "'Flatcar' not in guest_os_ansible_distribution" - - ansible.builtin.debug: - msg: "GOSC is supported for {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} with open-vm-tools {{ vmtools_version }} on vCenter Server {{ vcenter_version }} build {{ vcenter_build }}. See https://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf." + - name: "Display GOSC support status for {{ vm_guest_os_distribution }}" + ansible.builtin.debug: + msg: >- + GOSC is supported for {{ vm_guest_os_distribution }} with open-vm-tools {{ vmtools_version }} + on vCenter Server {{ vcenter_version }} build {{ vcenter_build }}. + See https://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf. when: gosc_is_supported | bool - - include_tasks: ../../common/skip_test_case.yml + - name: "Skip test case due to GOSC is not supported for {{ vm_guest_os_distribution }}" + include_tasks: ../../common/skip_test_case.yml vars: - skip_msg: "GOSC is not supported for {{ guest_os_ansible_distribution }} {{ guest_os_ansible_distribution_ver }} with open-vm-tools {{ vmtools_version }} on vCenter Server {{ vcenter_version }} build {{ vcenter_build }}. See https://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf." + skip_msg: >- + Skip test case {{ ansible_play_name }} GOSC is not supported for {{ vm_guest_os_distribution }} + with open-vm-tools {{ vmtools_version }} on + vCenter Server {{ vcenter_version }} build {{ vcenter_build }}. + See https://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf. skip_reason: "Not Supported" when: not gosc_is_supported | bool when: From 351cdb55c2abfa75a89cd97cee43e45102f79afc Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Tue, 20 Jun 2023 21:44:05 +0800 Subject: [PATCH 10/10] Address review comments Signed-off-by: Qi Zhang --- linux/deploy_vm/deploy_vm_from_iso.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/linux/deploy_vm/deploy_vm_from_iso.yml b/linux/deploy_vm/deploy_vm_from_iso.yml index e7193ebf7..0fd8c188f 100644 --- a/linux/deploy_vm/deploy_vm_from_iso.yml +++ b/linux/deploy_vm/deploy_vm_from_iso.yml @@ -53,12 +53,12 @@ when: "'freebsd' in guest_id" when: unattend_install_conf is undefined or not unattend_install_conf - - name: "warning: unattend_install_conf is undefined" + - name: "Display warning message about undefined unattend_install_conf" ansible.builtin.debug: - msg: "unattend_install_conf is not defined or set to a file path, will not generate unattend iso file" + msg: "unattend_install_conf is not defined or set to a file path, will not generate unattend ISO file" when: unattend_install_conf is undefined or not unattend_install_conf - - name: "Generate unattend install iso file" + - name: "Generate unattend install ISO file" include_tasks: create_unattend_install_iso.yml when: unattend_install_conf is defined and unattend_install_conf @@ -230,14 +230,14 @@ - name: "Wait for service {{ wait_service_name }} is running" include_tasks: ../utils/wait_for_service_status.yml vars: - - service_name: "{{ wait_service_name }}" - - wait_service_status: "running" + service_name: "{{ wait_service_name }}" + wait_service_status: "running" when: - guest_os_with_gui is defined - (guest_os_family in ["RedHat", "Suse"] or guest_os_ansible_distribution in ["Ubuntu", "Debian"]) - - name: "Eject unattend/seed iso and delete it from datastore" + - name: "Eject unattend/seed ISO and delete it from datastore" include_tasks: eject_del_unattend_install_iso.yml when: - transferred_unattend_iso is defined