From 4caccc6bcfda2285458b29bb7a32ac316fec156a Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Tue, 9 Jan 2024 17:57:49 -0600 Subject: [PATCH] Added Alma support --- TODO.txt | 4 +- distros/almalinux/8/amd64.pkrvars.hcl | 13 +++ distros/almalinux/8/disc/ks.cfg | 158 +++++++++++++++++++++++++ distros/almalinux/8/finalize.sh | 4 + distros/almalinux/8/qemu.sh | 6 + distros/almalinux/8/virtualbox.sh | 9 ++ distros/almalinux/8/vmware.sh | 4 + distros/almalinux/9/amd64.pkrvars.hcl | 13 +++ distros/almalinux/9/disc/ks.cfg | 161 ++++++++++++++++++++++++++ distros/almalinux/9/finalize.sh | 4 + distros/almalinux/9/qemu.sh | 6 + distros/almalinux/9/virtualbox.sh | 9 ++ distros/almalinux/9/vmware.sh | 4 + distros/almalinux/supports.yml | 10 ++ 14 files changed, 403 insertions(+), 2 deletions(-) create mode 100644 distros/almalinux/8/amd64.pkrvars.hcl create mode 100644 distros/almalinux/8/disc/ks.cfg create mode 100644 distros/almalinux/8/finalize.sh create mode 100644 distros/almalinux/8/qemu.sh create mode 100644 distros/almalinux/8/virtualbox.sh create mode 100644 distros/almalinux/8/vmware.sh create mode 100644 distros/almalinux/9/amd64.pkrvars.hcl create mode 100644 distros/almalinux/9/disc/ks.cfg create mode 100644 distros/almalinux/9/finalize.sh create mode 100644 distros/almalinux/9/qemu.sh create mode 100644 distros/almalinux/9/virtualbox.sh create mode 100644 distros/almalinux/9/vmware.sh create mode 100644 distros/almalinux/supports.yml diff --git a/TODO.txt b/TODO.txt index 944f042..b34fc50 100644 --- a/TODO.txt +++ b/TODO.txt @@ -6,14 +6,14 @@ Distros: * PopOS * Mint * Rocky -- Done -* Alma +* Alma -- Done * Oracle * Gentoo * Elementary OS * Manjaro Providers: -* VMWare -- Done +* VMWare -- Done, but can't seem to automate install * Parallels -- Requires money * Hyper-V -- Done diff --git a/distros/almalinux/8/amd64.pkrvars.hcl b/distros/almalinux/8/amd64.pkrvars.hcl new file mode 100644 index 0000000..379b8d1 --- /dev/null +++ b/distros/almalinux/8/amd64.pkrvars.hcl @@ -0,0 +1,13 @@ +distro = "almalinux" +version = "8" +iso = { + url = "https://mirrors.kernel.org/almalinux/8.9/isos/x86_64/AlmaLinux-8.9-x86_64-boot.iso" + checksum = "ab861d80c8b68634f3c16d414a4141759a082548ad7b251d8924675fa09decab" +} +boot_command = [ + "e", + "", + " inst.text inst.ks=cdrom:/ks.cfg", + "x" +] +cd_files = [ "distros/almalinux/8/disc/*" ] diff --git a/distros/almalinux/8/disc/ks.cfg b/distros/almalinux/8/disc/ks.cfg new file mode 100644 index 0000000..ab98110 --- /dev/null +++ b/distros/almalinux/8/disc/ks.cfg @@ -0,0 +1,158 @@ +url --mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/baseos +repo --name=AppStream --mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/appstream +network --bootproto=dhcp --activate +reboot + +text +keyboard --vckeymap us +lang en_US +skipx +rootpw --plaintext vagrant +firewall --disabled +timezone --utc UTC +services --enabled=vmtoolsd +# The biosdevname and ifnames options ensure we get "eth0" as our interface +# even in environments like virtualbox that emulate a real NW card +bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop" +zerombr +clearpart --all +autopart --type=plain + +user --name=vagrant --plaintext --password=vagrant + +%packages --instLangs=en +bash-completion +man-pages +bzip2 +rsync +nfs-utils +cifs-utils +chrony +yum-utils +hyperv-daemons +open-vm-tools +# Vagrant boxes aren't normally visible, no need for Plymouth +-plymouth +# Microcode updates cannot work in a VM +-microcode_ctl +# Firmware packages are not needed in a VM +-iwl100-firmware +-iwl1000-firmware +-iwl105-firmware +-iwl135-firmware +-iwl2000-firmware +-iwl2030-firmware +-iwl3160-firmware +-iwl3945-firmware +-iwl4965-firmware +-iwl5000-firmware +-iwl5150-firmware +-iwl6000-firmware +-iwl6000g2a-firmware +-iwl6050-firmware +-iwl7260-firmware +# Don't build rescue initramfs +-dracut-config-rescue +%end + +# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only +# works on systems with at least 2GB RAM (which excludes most Vagrant boxes) +# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169 +%addon com_redhat_kdump --disable +%end + +%post --erroronfail +dnf update -y + +# configure swap to a file +fallocate -l 2G /swapfile +chmod 600 /swapfile +mkswap /swapfile +echo "/swapfile none swap defaults 0 0" >> /etc/fstab + +# sudo +echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant +chmod 0440 /etc/sudoers.d/vagrant + +# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38 +cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF +DEVICE="eth0" +BOOTPROTO="dhcp" +ONBOOT="yes" +TYPE="Ethernet" +PERSISTENT_DHCLIENT="yes" +EOF + +# sshd: disable password authentication and DNS checks +ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd <> /etc/ssh/sshd_config + +# Decrease connection time by preventing reverse DNS lookups +# (see https://lists.centos.org/pipermail/centos-devel/2016-July/014981.html +# and man sshd for more information) +OPTIONS="-u0" +EOF + +# Fix for issue #76, regular users can gain admin privileges via su +ex -s /etc/pam.d/su <<'EOF' +# allow vagrant to use su, but prevent others from becoming root or vagrant +/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet$/ +:append +account [success=1 default=ignore] \\ + pam_succeed_if.so user = vagrant use_uid quiet +account required pam_succeed_if.so user notin root:vagrant +. +:update +:quit +EOF + +# systemd should generate a new machine id during the first boot, to +# avoid having multiple Vagrant instances with the same id in the local +# network. /etc/machine-id should be empty, but it must exist to prevent +# boot errors (e.g. systemd-journald failing to start). +:>/etc/machine-id + +echo 'vag' > /etc/yum/vars/infra + +# Blacklist the floppy module to avoid probing timeouts +echo blacklist floppy > /etc/modprobe.d/nofloppy.conf +chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf + +# Customize the initramfs +pushd /etc/dracut.conf.d +# Enable VMware PVSCSI support for VMware Fusion guests. +echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf +echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf +# There's no floppy controller, but probing for it generates timeouts +echo 'omit_drivers+=" floppy "' > nofloppy.conf +popd +# Fix the SELinux context of the new files +restorecon -f - <&1 | tee /root/vbox_addon_install.log +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/almalinux/8/vmware.sh b/distros/almalinux/8/vmware.sh new file mode 100644 index 0000000..058afc2 --- /dev/null +++ b/distros/almalinux/8/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +dnf install -y open-vm-tools diff --git a/distros/almalinux/9/amd64.pkrvars.hcl b/distros/almalinux/9/amd64.pkrvars.hcl new file mode 100644 index 0000000..c1b4d1c --- /dev/null +++ b/distros/almalinux/9/amd64.pkrvars.hcl @@ -0,0 +1,13 @@ +distro = "almalinux" +version = "9" +iso = { + url = "https://mirrors.kernel.org/almalinux/9.3/isos/x86_64/AlmaLinux-9.3-x86_64-boot.iso" + checksum = "af5377a1d16bbe599ea91a8761ad645f2f54687075802bdc0c0703ee610182e9" +} +boot_command = [ + "e", + "", + " inst.text inst.ks=cdrom:/ks.cfg", + "x" +] +cd_files = [ "distros/almalinux/9/disc/*" ] diff --git a/distros/almalinux/9/disc/ks.cfg b/distros/almalinux/9/disc/ks.cfg new file mode 100644 index 0000000..043cd64 --- /dev/null +++ b/distros/almalinux/9/disc/ks.cfg @@ -0,0 +1,161 @@ +url --mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/baseos +repo --name=AppStream --mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/appstream +network --bootproto=dhcp --activate +reboot + +text +keyboard --vckeymap us +lang en_US +skipx +rootpw --plaintext vagrant +firewall --disabled +timezone --utc UTC +services --enabled=vmtoolsd +# The biosdevname and ifnames options ensure we get "eth0" as our interface +# even in environments like virtualbox that emulate a real NW card +bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop" +clearpart --all +autopart --type=plain +zerombr + +user --name=vagrant --plaintext --password=vagrant + +%packages --inst-langs=en +bash-completion +man-pages +bzip2 +rsync +nfs-utils +cifs-utils +chrony +yum-utils +hyperv-daemons +open-vm-tools +# Vagrant boxes aren't normally visible, no need for Plymouth +-plymouth +# Microcode updates cannot work in a VM +-microcode_ctl +# Firmware packages are not needed in a VM +-iwl100-firmware +-iwl1000-firmware +-iwl105-firmware +-iwl135-firmware +-iwl2000-firmware +-iwl2030-firmware +-iwl3160-firmware +-iwl3945-firmware +-iwl4965-firmware +-iwl5000-firmware +-iwl5150-firmware +-iwl6000-firmware +-iwl6000g2a-firmware +-iwl6050-firmware +-iwl7260-firmware +# Don't build rescue initramfs +-dracut-config-rescue +%end + +# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only +# works on systems with at least 2GB RAM (which excludes most Vagrant boxes) +# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169 +%addon com_redhat_kdump --disable +%end + +%post --erroronfail +dnf update -y + +# configure swap to a file +fallocate -l 2G /swapfile +chmod 600 /swapfile +mkswap /swapfile +echo "/swapfile none swap defaults 0 0" >> /etc/fstab + +# sudo +echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant +chmod 0440 /etc/sudoers.d/vagrant + +# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38 +cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF +DEVICE="eth0" +BOOTPROTO="dhcp" +ONBOOT="yes" +TYPE="Ethernet" +PERSISTENT_DHCLIENT="yes" +EOF + +# sshd: disable password authentication and DNS checks +ex -s /etc/ssh/sshd_config <>/etc/sysconfig/sshd < /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf +PubkeyAcceptedKeyTypes +ssh-rsa +EOF + +# Decrease connection time by preventing reverse DNS lookups +# (see https://lists.centos.org/pipermail/centos-devel/2016-July/014981.html +# and man sshd for more information) +OPTIONS="-u0" +EOF + +# Fix for issue #76, regular users can gain admin privileges via su +ex -s /etc/pam.d/su <<'EOF' +# allow vagrant to use su, but prevent others from becoming root or vagrant +/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet$/ +:append +account [success=1 default=ignore] \ + pam_succeed_if.so user = vagrant use_uid quiet +account required pam_succeed_if.so user notin root:vagrant +. +:update +:quit +EOF + +# systemd should generate a new machine id during the first boot, to +# avoid having multiple Vagrant instances with the same id in the local +# network. /etc/machine-id should be empty, but it must exist to prevent +# boot errors (e.g. systemd-journald failing to start). +:>/etc/machine-id + +echo 'vag' > /etc/yum/vars/infra + +# Blacklist the floppy module to avoid probing timeouts +echo blacklist floppy > /etc/modprobe.d/nofloppy.conf +chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf + +# Customize the initramfs +pushd /etc/dracut.conf.d +# Enable VMware PVSCSI support for VMware Fusion guests. +echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf +echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf +# There's no floppy controller, but probing for it generates timeouts +echo 'omit_drivers+=" floppy "' > nofloppy.conf +popd +# Fix the SELinux context of the new files +restorecon -f - <&1 | tee /root/vbox_addon_install.log +umount /mnt +rm /home/vagrant/VBoxGuestAdditions.iso diff --git a/distros/almalinux/9/vmware.sh b/distros/almalinux/9/vmware.sh new file mode 100644 index 0000000..058afc2 --- /dev/null +++ b/distros/almalinux/9/vmware.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -ex + +dnf install -y open-vm-tools diff --git a/distros/almalinux/supports.yml b/distros/almalinux/supports.yml new file mode 100644 index 0000000..533b6df --- /dev/null +++ b/distros/almalinux/supports.yml @@ -0,0 +1,10 @@ +8: &supp + - arch: amd64 + provider: qemu + - arch: amd64 + provider: virtualbox-iso + - arch: amd64 + provider: vmware-iso + - arch: amd64 + provider: hyperv-iso +9: *supp