Skip to content

Commit

Permalink
[Pardus] suppport unattended install for Pardus 21.x (#462)
Browse files Browse the repository at this point in the history
Signed-off-by: ZouYuhua <zouy@vmware.com>
  • Loading branch information
ZouYuhua authored May 11, 2023
1 parent 71ebf81 commit 4be57da
Show file tree
Hide file tree
Showing 11 changed files with 711 additions and 305 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ This project supports below scenarios for end-to-end guest operating system vali
| UnionTech OS Server 20 1050a | :heavy_check_mark: | | :heavy_check_mark: |
| Fedora Server 36 and later | :heavy_check_mark: | | :heavy_check_mark: |
| ProLinux Server 7.9, 8.5 | :heavy_check_mark: | | :heavy_check_mark: |
| Pardus 21.2 Server and later | :heavy_check_mark: | | :heavy_check_mark: |
| Pardus 21.2 XFCE Desktop and later | :heavy_check_mark: | | :heavy_check_mark: |

Note: This compatible guest operating systems list is used for this project only. For guest operating system support status on ESXi, please refer to [VMware Compatibility Guide](https://www.vmware.com/resources/compatibility/search.php?deviceCategory=software&testConfig=16).

Expand Down
252 changes: 252 additions & 0 deletions autoinstall/Pardus/preseed.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
#_preseed_V1
#### Contents of the preconfiguration file (for pardus)

### Localization
# Preseeding only locale sets language, country and locale.
d-i debconf/language string en_US:en
d-i debian-installer/country string US
d-i debian-installer/fallbacklocale string en_US
d-i debian-installer/language string en_US:en
d-i languagechooser/locale string en
d-i debian-installer/locale string en_US

# Keyboard selection.
d-i keyboard-configuration/xkb-keymap select us
d-i keyboard-configuration/variant select English (US)

### Network configuration
d-i netcfg/enable boolean true

# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto
d-i netcfg/use_dhcp string true

# To set a different link detection timeout (default is 3 seconds).
# Values are interpreted as seconds.
d-i netcfg/link_wait_timeout string 10

# If you have a slow dhcp server and the installer times out waiting for
# it, this might be useful.
d-i netcfg/dhcp_timeout string 60

# If you want the preconfiguration file to work on systems both with and
# without a dhcp server, uncomment these lines and the static network
# configuration below.
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 pardus
d-i netcfg/get_domain string unassigned-domain

### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true

# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string US/Eastern

# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true
# NTP server to use. The default is almost always fine here.
#d-i clock-setup/ntp-server string ntp.example.com
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us

### Account setup
# Root password encrypted using a crypt(3) hash.
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password {{ vm_password_hash }}

{% if new_user is defined and new_user != 'root' %}
# To create a normal user account.
d-i passwd/user-fullname string {{ new_user }}
d-i passwd/username string {{ new_user }}
# Normal user's password encrypted using a crypt(3) hash.
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
{% endif %}

### Partitioning
## Partitioning example
# Specify a disk to partition.
# For example, to use the first SCSI/SATA hard disk:
d-i partman-auto/disk string /dev/{{ boot_disk_name }}
# In addition, you'll need to specify the method to use.
# The presently available methods are:
# - regular: use the usual partition types for your architecture
# - lvm: use LVM to partition the disk
# - crypto: use LVM within an encrypted partition
d-i partman-auto/method string lvm

# You can define the amount of space that will be used for the LVM volume
# group. It can either be a size with its unit (eg. 20 GB), a percentage of
# free space or the 'max' keyword.
d-i partman-auto-lvm/guided_size string max

# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /var, and /tmp partitions
d-i partman-auto/choose_recipe select atomic

# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

# Force UEFI booting ('BIOS compatibility' will be lost). Default: false.
{% if firmware is defined and firmware == 'efi' %}
d-i partman-efi/non_efi_system boolean true

# Ensure the partition table is GPT - this is required for EFI
d-i partman-partitioning/choose_label string gpt
d-i partman-partitioning/default_label string gpt
{% endif %}

# This makes partman automatically partition without confirmation.
d-i partman-md/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

# Default repository information (don't include codename data, d-i figures it
# out from what's available in the ISO)
#d-i mirror/country string manually
#d-i mirror/http/hostname string depo.pardus.org.tr
#d-i mirror/http/hostname seen false
#d-i mirror/http/directory string /pardus
#d-i mirror/http/proxy string
# Don't add any security and updates repo to avoid an upgrade during installation
# We might need these later, think about the following lines.
#d-i apt-setup/services-select multiselect
#d-i apt-setup/security_host string depo.pardus.org.tr
#d-i apt-setup/security_path string /guvenlik

### Apt setup
d-i apt-setup/use_mirror boolean false
d-i apt-setup/cdrom/set-first boolean false
d-i apt-setup/cdrom/set-next boolean false
d-i apt-setup/cdrom/set-failed boolean false
d-i apt-setup/disable-cdrom-entries boolean true
d-i apt-setup/enable-source-repositories boolean true

# Disable upgrading while installation
d-i pkgsel/upgrade select none

### Package selection
#tasksel tasksel/first multiselect standard, web-server, kde-desktop
tasksel tasksel/first multiselect standard, desktop
tasksel tasksel/desktop multiselect xfce

# Individual additional packages to install
# There is no open-vm-tools-desktop openssh-server and cloud-init in CDROM
#d-i pkgsel/include string build-essential open-vm-tools openssh-server sg3-utils vim

# Policy for applying updates. May be "none" (no automatic updates),
# "unattended-upgrades" (install security updates automatically), or
# "landscape" (manage system with Landscape).
d-i pkgsel/update-policy select none

# Some versions of the installer can report back on what software you have
# installed, and what software you use. The default is not to report back,
# but sending reports helps the project determine what software is most
# popular and should be included on the first CD/DVD.
popularity-contest popularity-contest/participate boolean false

### Boot loader installation
# Grub is the boot loader (for x86).

# This is fairly safe to set, it makes grub install automatically to the UEFI
# partition/boot record if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true

# Due notably to potential USB sticks, the location of the primary drive can
# not be determined safely in general, so this needs to be specified:
#d-i grub-installer/bootdev string /dev/sda
# To install to the primary device (assuming it is not a USB stick):
d-i grub-installer/bootdev string default

# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

# This will prevent the installer from ejecting the CD during the reboot,
# which is useful in some situations.
#d-i cdrom-detect/eject boolean true

### Preseeding other packages
# Depending on what software you choose to install, or if things go wrong
# during the installation process, it's possible that other questions may
# be asked. You can preseed those too, of course. To get a list of every
# possible question that could be asked during an install, do an
# installation, and then run these commands:
debconf-get-selections --installer > /target/root/preceed.cfg
debconf-get-selections >> /target/root/preceed.cfg

# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
# The packages not available in CDROM will be installed from online repo.
d-i preseed/late_command string \
echo "Check network ..." > /target/dev/ttyS0; \
ip addr show > /target/dev/ttyS0; \
echo "Linkup network ..." > /target/dev/ttyS0; \
chroot /target /sbin/ifconfig $(/sbin/ifconfig -a | grep '^[a-z]' | cut -d: -f1 | head -n 1) up; \
sleep 5; \
echo "Check network after linkup ..." > /target/dev/ttyS0; \
ip addr show > /target/dev/ttyS0; \
echo "Check file /etc/apt/sources.list ..." > /target/dev/ttyS0; \
cat /target/etc/apt/sources.list > /target/dev/ttyS0; \
if [ -f "/target/etc/os-release" ];\
then\
echo "Add offical repo ..." > /target/dev/ttyS0;\
codename=$(cat /target/etc/os-release | grep PARDUS_CODENAME | cut -d= -f2);\
echo "deb http://depo.pardus.org.tr/pardus $codename main contrib non-free" >> /target/etc/apt/sources.list;\
echo "deb http://depo.pardus.org.tr/guvenlik $codename main contrib non-free" >> /target/etc/apt/sources.list;\
cat /target/etc/apt/sources.list > /target/dev/ttyS0;\
fi; \
echo "Update repository ..." > /target/dev/ttyS0; \
chroot /target apt-get update -y > /dev/ttyS0; \
echo "Install openssh-server ..." > /target/dev/ttyS0; \
chroot /target apt-get install -y --no-upgrade openssh-server > /dev/ttyS0; \
echo "Install packages ..." > /target/dev/ttyS0; \
chroot /target apt-get install -y --force-yes build-essential open-vm-tools sg3-utils vim > /dev/ttyS0; \
if [ -f "/target/usr/bin/Xorg" ];\
then\
echo "Install package open-vm-tools-desktop ..." > /target/dev/ttyS0;\
chroot /target apt-get install -y open-vm-tools-desktop > /target/dev/ttyS0;\
fi; \
{% if new_user is defined and new_user != 'root' %}
echo '{{ new_user }} ALL=(ALL) NOPASSWD:ALL' >/target/etc/sudoers.d/{{ new_user }}; \
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; \
chown --recursive root:root /target/root/.ssh; \
chmod 0644 /target/root/.ssh/authorized_keys; \
echo "Config sshd to enable root login ..." > /target/dev/ttyS0; \
touch /target/etc/ssh/sshd_config.d/root.conf; \
echo "PasswordAuthentication yes" >> /target/etc/ssh/sshd_config.d/root.conf; \
echo "PermitRootLogin yes" >> /target/etc/ssh/sshd_config.d/root.conf; \
echo "{{ autoinstall_complete_msg }}" > /target/dev/ttyS0
1 change: 1 addition & 0 deletions autoinstall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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.
19. For FreeBSD 13 or later unattend auto-install, please use file FreeBSD/installerconfig.
20. For Pardus 21.2 Server and XFCE Desktop or later unattend auto-install, please use file Pardus/preseed.cfg.

# Notes
## For Windows
Expand Down
1 change: 0 additions & 1 deletion common/test_rescue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
- vm_dir_name
- vm_serial_port_output_file is defined
- vm_serial_port_output_file
- guest_id is match('freebsd')

- name: "Take a snapshot at VM current state"
include_tasks: vm_take_snapshot.yml
Expand Down
8 changes: 6 additions & 2 deletions linux/deploy_vm/create_unattend_install_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
- unattend_install_conf is not match('Debian')
- unattend_install_conf is not match('Ubuntu/Desktop/Ubiquity')
- unattend_install_conf is not match('FreeBSD')
- unattend_install_conf is not match('Pardus')

- name: "Build unattend install config file into OS ISO image"
include_tasks: rebuild_unattend_install_iso.yml
Expand All @@ -74,7 +75,8 @@
unattend_install_conf is match('Photon') or
unattend_install_conf is match('Debian') or
unattend_install_conf is match('Ubuntu/Desktop/Ubiquity') or
unattend_install_conf is match('FreeBSD')
unattend_install_conf is match('FreeBSD') or
unattend_install_conf is match('Pardus')
when:
- unattend_install_conf is not match('Ubuntu/Server/')
- unattend_install_conf is not match('Ubuntu/Desktop/Subiquity')
Expand Down Expand Up @@ -143,6 +145,7 @@
- unattend_install_conf is not match('Debian')
- unattend_install_conf is not match('Ubuntu/Desktop/Ubiquity')
- unattend_install_conf is not match('FreeBSD')
- unattend_install_conf is not match('Pardus')

- name: "Replace original install ISO file with unattend install ISO file"
ansible.builtin.set_fact:
Expand All @@ -152,7 +155,8 @@
unattend_install_conf is match('Photon') or
unattend_install_conf is match('Debian') or
unattend_install_conf is match('Ubuntu/Desktop/Ubiquity') or
unattend_install_conf is match('FreeBSD')
unattend_install_conf is match('FreeBSD') or
unattend_install_conf is match('Pardus')
- name: "Copy generated unattend install config file to log folder"
ansible.builtin.copy:
Expand Down
13 changes: 13 additions & 0 deletions linux/deploy_vm/deploy_vm_from_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,19 @@
cdrom_controller_num: "{{ vm_cdroms[0].controller_number | int }}"
cdrom_unit_num: "{{ vm_cdroms[0].unit_number | int }}"
when: guest_os_ansible_distribution == "Ubuntu"

- name: "Download serial output file before removing serial port"
include_tasks: ../../common/esxi_download_datastore_file.yml
vars:
src_datastore: "{{ datastore }}"
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:
- 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

Expand Down
Loading

0 comments on commit 4be57da

Please sign in to comment.