From 455278d495f702e486ae6be4920a51b01ee31ac5 Mon Sep 17 00:00:00 2001 From: chrisjsimpson Date: Sun, 12 Nov 2023 21:40:11 +0000 Subject: [PATCH] #13 more reliable udev disk identify & ensure packages present --- .../get-first-two-disks-install-openzfs-fedora-root.sh | 10 ++++++---- src/playbooks/templates/interfaces.j2 | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) rename src/{ => playbooks/scripts}/get-first-two-disks-install-openzfs-fedora-root.sh (97%) create mode 100644 src/playbooks/templates/interfaces.j2 diff --git a/src/get-first-two-disks-install-openzfs-fedora-root.sh b/src/playbooks/scripts/get-first-two-disks-install-openzfs-fedora-root.sh similarity index 97% rename from src/get-first-two-disks-install-openzfs-fedora-root.sh rename to src/playbooks/scripts/get-first-two-disks-install-openzfs-fedora-root.sh index 445b0e8..f6d04f3 100755 --- a/src/get-first-two-disks-install-openzfs-fedora-root.sh +++ b/src/playbooks/scripts/get-first-two-disks-install-openzfs-fedora-root.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -x +set -eux -o pipefail # The two smallest disks are always used as the boot and root pool # as a ZFS mirror. @@ -9,6 +9,9 @@ set -x # - Based on manual steps in OpenZFS docs: # https://openzfs.github.io/openzfs-docs/Getting%20Started/Fedora/Root%20on%20ZFS.html#:~:text=page%20for%20examples.-,Declare%20disk%20array,-DISK%3D%27/dev +install_required_packages() { + apk add lsblk eudev jq curl arch-install-scripts eudev sgdisk wipefs parted findmnt +} declare_disk_array() { # For each disk found, get it's /dev/disk/by-id address by querying udevadm @@ -19,7 +22,7 @@ declare_disk_array() { for DISK_ADDRESS in $DISK_ADDRESSES do - DISK_UDEV_PATH=/dev/$(udevadm info --query=symlink --name=/dev/"$DISK_ADDRESS"| cut -d ' ' -f 1) + DISK_UDEV_PATH=/dev/$(udevadm info --query=symlink --name=/dev/"$DISK_ADDRESS"| awk '{for(i=1; i<=NF; i++) if($i ~ /^disk\/by-id\//) {print $i; exit}}') # Append disk to $DISK list DISK="$DISK $DISK_UDEV_PATH" done @@ -165,7 +168,6 @@ format_and_mount_ESP(){ } download_extract_minimal_Fedora_root_filesystem(){ - apk add curl curl --fail-early --fail -L \ https://dl.fedoraproject.org/pub/fedora/linux/releases/38/Container/x86_64/images/Fedora-Container-Base-38-1.6.x86_64.tar.xz \ -o rootfs.tar.gz @@ -200,7 +202,6 @@ enable_community_repo(){ generate_fstab(){ - apk add arch-install-scripts genfstab -t PARTUUID "${MNT}" \ | grep -v swap \ | sed "s|vfat.*rw|vfat rw,x-systemd.idle-timeout=1min,x-systemd.automount,noauto,nofail|" \ @@ -417,6 +418,7 @@ ZFS_export_all_pools(){ zpool export -a } +install_required_packages declare_disk_array set_mount_point set_swap_size diff --git a/src/playbooks/templates/interfaces.j2 b/src/playbooks/templates/interfaces.j2 new file mode 100644 index 0000000..2d35ca4 --- /dev/null +++ b/src/playbooks/templates/interfaces.j2 @@ -0,0 +1,4 @@ +iface {{ server_active_gateway_interface.stdout }} inet static + address {{ server_public_ip.stdout }} + netmask {{ server_ip_netmask.stdout }} + gateway {{ server_gateway_ip.stdout }}