Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linux] Fix Debian 12 auto installation failure #474

Merged
merged 10 commits into from
Jun 26, 2023
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
50 changes: 43 additions & 7 deletions autoinstall/Debian/10/preseed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -221,14 +223,48 @@ 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; \
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; \
in-target chown --recursive root:root /root/.ssh; \
in-target chmod 0644 /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 '"'); \
echo "Debian release version is $version, codename is $codename" > /target/dev/ttyS0; \
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; \
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 >/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; \
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 \
locales-all rdma-core rdmacm-utils ibverbs-utils >/dev/ttyS0; \
fi; \
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; \
sed -i "s/^X-GNOME-HiddenUnderSystemd *=.*/X-GNOME-HiddenUnderSystemd=false/" $gnome_initial_cfg; \
fi; \
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
4 changes: 2 additions & 2 deletions autoinstall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion common/get_guest_system_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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('') }}"
Expand Down
Loading