From ea5ed606f0526815086496c0a890bdc6bedb87d1 Mon Sep 17 00:00:00 2001 From: Ondrej Famera Date: Mon, 6 Jun 2022 14:58:19 +0900 Subject: [PATCH] Add files for automated generation of openSUSE images - autoyast files, new hack files, virt-install script This partially addresses the #11 Issue. --- opensuse/README | 1 - opensuse/autoyast/opensuse-15.0.xml | 335 ++++++++++++++++++ opensuse/autoyast/opensuse-15.3.xml | 335 ++++++++++++++++++ opensuse/autoyast/virt-install-opensuse.sh | 21 ++ opensuse/hacks/6g_opensuse-15.0-hacks.sh | 28 ++ ...-15-hacks.sh => 6g_opensuse-15.3-hacks.sh} | 5 + 6 files changed, 724 insertions(+), 1 deletion(-) create mode 100644 opensuse/autoyast/opensuse-15.0.xml create mode 100644 opensuse/autoyast/opensuse-15.3.xml create mode 100755 opensuse/autoyast/virt-install-opensuse.sh create mode 100755 opensuse/hacks/6g_opensuse-15.0-hacks.sh rename opensuse/hacks/{6g_opensuse-15-hacks.sh => 6g_opensuse-15.3-hacks.sh} (75%) diff --git a/opensuse/README b/opensuse/README index b15f43e..ba876cd 100644 --- a/opensuse/README +++ b/opensuse/README @@ -8,7 +8,6 @@ - no graphic card - serial console configured for system and grub - hostname configured according to VM_NAME from fast-vm -- [!!] system installd by hand with 'Server' profile (minimal package selection) - system would be running for the first time after installation ## Drive layout - 6 GB drive diff --git a/opensuse/autoyast/opensuse-15.0.xml b/opensuse/autoyast/opensuse-15.0.xml new file mode 100644 index 0000000..7636f76 --- /dev/null +++ b/opensuse/autoyast/opensuse-15.0.xml @@ -0,0 +1,335 @@ + + + + + + resume=/dev/os15vg/swap_lv console=ttyS0,115200n8 mitigations=auto + auto + auto + false + false + serial --unit=0 --speed=115200 --parity=no --word=8 + serial + 5 + + grub2 + + + false + + + public + true + off + true + + + For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted. + false + public + + ssh + dhcpv6-client + + Public + default + + + + + + false + false + true + false + false + + + false + false + false + false + false + false + + + + + + + 127.0.0.1 + + localhost + + + + ::1 + + localhost ipv6-localhost ipv6-loopback + + + + fe00::0 + + ipv6-localnet + + + + ff00::0 + + ipv6-mcastprefix + + + + ff02::1 + + ipv6-allnodes + + + + ff02::2 + + ipv6-allrouters + + + + ff02::3 + + ipv6-allhosts + + + + + + + + AUTO + + + true + localhost + auto + + + + + dhcp + eth0 + hotplug + + + true + false + false + + false + false + + + + + /dev/os15vg + false + false + + + true + swap + false + swap_lv + swap + device + false + false + 268435456 + 1 + 0 + + + true + true + btrfs + false + root_lv + / + device + false + false + 5368709120 + 1 + 0 + + + true + home + + + true + boot/grub2/x86_64-efi + + + true + boot/grub2/i386-pc + + + true + root + + + true + opt + + + true + usr/local + + + true + tmp + + + true + srv + + + false + var + + + + + + 4194304 + CT_LVM + + + /dev/sda + gpt + false + + + true + 263 + false + 263 + 1 + false + 8388608 + + + true + 142 + false + os15vg + 142 + 2 + false + 6432996864 + + + CT_DISK + all + + + + + true + true + 0 + + + true + true + 0 + + + true + true + 0 + + + true + true + 0 + + + + + + + + + + + + + + sshd + + + + + false + + wicked + openssh + openSUSE-release + numactl + lvm2 + kexec-tools + irqbalance + grub2 + glibc + firewalld + e2fsprogs + btrfsprogs + autoyast2 + + + apparmor + base + enhanced_base + minimal_base + yast2_basis + + + openSUSE + + + + 100 + + /home + -1 + true + /bin/bash + /etc/skel + 022 + + + + + false + root + 0 + /root + false + + -1 + 99999 + 0 + 7 + + /bin/bash + 0 + testtest + root + + + diff --git a/opensuse/autoyast/opensuse-15.3.xml b/opensuse/autoyast/opensuse-15.3.xml new file mode 100644 index 0000000..888fb46 --- /dev/null +++ b/opensuse/autoyast/opensuse-15.3.xml @@ -0,0 +1,335 @@ + + + + + + resume=/dev/os15vg/swap_lv console=ttyS0,115200n8 mitigations=auto + auto + auto + false + false + serial --unit=0 --speed=115200 --parity=no --word=8 + serial + 5 + + grub2 + + + false + + + public + true + off + true + + + For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted. + false + public + + ssh + dhcpv6-client + + Public + default + + + + + + false + false + true + false + false + + + false + false + false + false + false + false + + + + + + + 127.0.0.1 + + localhost + + + + ::1 + + localhost ipv6-localhost ipv6-loopback + + + + fe00::0 + + ipv6-localnet + + + + ff00::0 + + ipv6-mcastprefix + + + + ff02::1 + + ipv6-allnodes + + + + ff02::2 + + ipv6-allrouters + + + + ff02::3 + + ipv6-allhosts + + + + + + + + AUTO + + + true + localhost + auto + + + + + dhcp + eth0 + hotplug + + + true + true + false + + false + false + + + + + /dev/os15vg + false + false + + + true + swap + false + swap_lv + swap + device + false + false + 268435456 + 1 + 0 + + + true + true + btrfs + false + root_lv + / + device + false + false + 5368709120 + 1 + 0 + + + true + home + + + true + boot/grub2/x86_64-efi + + + true + boot/grub2/i386-pc + + + true + root + + + true + opt + + + true + usr/local + + + true + tmp + + + true + srv + + + false + var + + + + + + 4194304 + CT_LVM + + + /dev/sda + gpt + false + + + true + 263 + false + 263 + 1 + false + 8388608 + + + true + 142 + false + os15vg + 142 + 2 + false + 6432996864 + + + CT_DISK + all + + + + + true + true + 0 + + + true + true + 0 + + + true + true + 0 + + + true + true + 0 + + + + + + + + + + + + + + sshd + + + + + false + + wicked + openssh + openSUSE-release + numactl + lvm2 + kexec-tools + irqbalance + grub2 + glibc + firewalld + e2fsprogs + btrfsprogs + autoyast2 + + + apparmor + base + enhanced_base + minimal_base + yast2_basis + + + Leap + + + + 100 + + /home + -1 + true + /bin/bash + /etc/skel + 022 + + + + + false + root + 0 + /root + false + + -1 + 99999 + 0 + 7 + + /bin/bash + 0 + testtest + root + + + diff --git a/opensuse/autoyast/virt-install-opensuse.sh b/opensuse/autoyast/virt-install-opensuse.sh new file mode 100755 index 0000000..dd847d5 --- /dev/null +++ b/opensuse/autoyast/virt-install-opensuse.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# example: ./$0 /dev/vg_ssd/fastvm-os-15.3 /mnt/iso_storage/opensuse/openSUSE-Leap-15.3-3-DVD-x86_64-Media.iso autoyast.xml +BASE_IMAGE_LV="$1" +ISO_LOCATION="$2" +KICKSTART="$3" + +virt-install \ +--connect qemu:///system \ +--name opensuse-15-fastvm-install \ +--ram 1024 --cpu host-model-only --vcpus 2 \ +--network network=default,model=virtio,link_state=down,mac=52:54:00:00:be:ef \ +--os-variant=opensuse15.3 \ +--disk path=$BASE_IMAGE_LV,bus=scsi,discard=unmap,format=raw \ +--controller scsi,model=virtio-scsi \ +--location $ISO_LOCATION \ +--extra-args="autoyast=file:///$(basename $KICKSTART) textmode=1 console=ttyS0,115200n8" \ +--initrd-inject=$KICKSTART \ +--noreboot \ +--nographics + +virsh --connect qemu:///system undefine opensuse-15-fastvm-install diff --git a/opensuse/hacks/6g_opensuse-15.0-hacks.sh b/opensuse/hacks/6g_opensuse-15.0-hacks.sh new file mode 100755 index 0000000..3b7ca93 --- /dev/null +++ b/opensuse/hacks/6g_opensuse-15.0-hacks.sh @@ -0,0 +1,28 @@ +#!/bin/bash +## test if guestfish command is present +which guestfish 2>&1 > /dev/null +if [ "$?" != 0 ]; then + echo "[!!!] Command 'guestfish' not found (Install it!). Making changes to VM FAILED." + exit 1 +fi +## using direct backend to avoid selinux issues on fedora for now +export LIBGUESTFS_BACKEND=direct +## hostname +VM_HOSTNAME=$(echo $VM_NAME|sed -e 's/\./-/g; s/_/-/g') +## timezone of hypervisor +timezone=$(readlink /etc/localtime | sed 's/^.*zoneinfo\/\(.*\)$/\1/') + +guestfish -a "/dev/$THINPOOL_VG/$VM_NAME" -m /dev/os15vg/root_lv < /etc/sysconfig/network/ifcfg-eth0' +EOF diff --git a/opensuse/hacks/6g_opensuse-15-hacks.sh b/opensuse/hacks/6g_opensuse-15.3-hacks.sh similarity index 75% rename from opensuse/hacks/6g_opensuse-15-hacks.sh rename to opensuse/hacks/6g_opensuse-15.3-hacks.sh index 852078a..36efdc4 100755 --- a/opensuse/hacks/6g_opensuse-15-hacks.sh +++ b/opensuse/hacks/6g_opensuse-15.3-hacks.sh @@ -18,4 +18,9 @@ sh 'sed -i "s/.*/$VM_HOSTNAME/" /etc/hostname' # change timezone of machine to match hypervisor sh 'rm -f /etc/localtime' sh 'ln -s /usr/share/zoneinfo/$timezone /etc/localtime' +# make first nic to be detected as eth0 (remove installation nic config) +sh 'rm -f /etc/udev/rules.d/70-persistent-net.rules' +# FIXME remove quiet boot option +sh 'sed -i "s/quiet//" /boot/grub2/grub.cfg' +sh 'sed -i "s/quiet//" /etc/default/grub' EOF