Big bang
This commit is contained in:
66
03-build-autoinstall-isos.sh
Executable file
66
03-build-autoinstall-isos.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
# Render the per-node answer files and bake them into bootable
|
||||
# "Automated Installation" ISOs using proxmox-auto-install-assistant, which we
|
||||
# run inside a debian:trixie container (the tool isn't packaged for Fedora).
|
||||
set -euo pipefail
|
||||
source "$(dirname "$0")/lab.env"
|
||||
|
||||
sudo -v # prompt for the sudo password once, up front
|
||||
|
||||
PUBKEY="$(cat "$SSH_PUB")"
|
||||
|
||||
echo "==> Rendering answer files into $BUILD_DIR"
|
||||
for n in 1 2; do
|
||||
src="${SCRIPT_DIR}/answer-pve${n}.toml"
|
||||
out="${BUILD_DIR}/answer-pve${n}.toml"
|
||||
sed -e "s|@@ROOT_PASSWORD@@|${ROOT_PASSWORD}|g" \
|
||||
-e "s|@@SSH_PUBKEY@@|${PUBKEY}|g" \
|
||||
"$src" > "$out"
|
||||
done
|
||||
|
||||
# proxmox-auto-install-assistant needs to read the source ISO and write the
|
||||
# output ISO. Stage them in BUILD_DIR (user-writable, bind-mounted into docker),
|
||||
# then copy the results into the libvirt pool dir.
|
||||
echo "==> Staging source ISO into build dir"
|
||||
sudo cp -n "${LIB_DIR}/${ISO_FILE}" "${BUILD_DIR}/${ISO_FILE}"
|
||||
sudo chown "$(id -u):$(id -g)" "${BUILD_DIR}/${ISO_FILE}"
|
||||
|
||||
echo "==> Building auto-install ISOs in debian:trixie container"
|
||||
# NOTE: ':z' relabels the bind mount for SELinux so the container can read it
|
||||
# (without it, Fedora's SELinux denies the container access to host files).
|
||||
docker run --rm -v "${BUILD_DIR}:/work:z" -w /work debian:trixie bash -euc '
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq curl gnupg ca-certificates >/dev/null
|
||||
install -d /etc/apt/keyrings
|
||||
curl -fsSL https://enterprise.proxmox.com/debian/proxmox-release-trixie.gpg \
|
||||
-o /etc/apt/keyrings/proxmox-release-trixie.gpg
|
||||
echo "deb [signed-by=/etc/apt/keyrings/proxmox-release-trixie.gpg] http://download.proxmox.com/debian/pve trixie pve-no-subscription" \
|
||||
> /etc/apt/sources.list.d/pve.list
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq proxmox-auto-install-assistant >/dev/null
|
||||
for n in 1 2; do
|
||||
echo "--- validating answer-pve${n}.toml ---"
|
||||
proxmox-auto-install-assistant validate-answer "/work/answer-pve${n}.toml"
|
||||
echo "--- baking pve${n}-auto.iso ---"
|
||||
rm -f "/work/pve${n}-auto.iso"
|
||||
proxmox-auto-install-assistant prepare-iso "/work/'"${ISO_FILE}"'" \
|
||||
--fetch-from iso \
|
||||
--answer-file "/work/answer-pve${n}.toml" \
|
||||
--output "/work/pve${n}-auto.iso"
|
||||
done
|
||||
'
|
||||
|
||||
echo "==> Publishing ISOs to ${LIB_DIR}"
|
||||
for n in 1 2; do
|
||||
sudo cp -f "${BUILD_DIR}/pve${n}-auto.iso" "${LIB_DIR}/pve${n}-auto.iso"
|
||||
done
|
||||
command -v restorecon >/dev/null && sudo restorecon -R "$LIB_DIR" || true
|
||||
# tidy the staged copy of the big source ISO
|
||||
rm -f "${BUILD_DIR}/${ISO_FILE}"
|
||||
|
||||
echo
|
||||
echo "Auto-install ISOs ready:"
|
||||
ls -lh "${LIB_DIR}"/pve1-auto.iso "${LIB_DIR}"/pve2-auto.iso 2>/dev/null || \
|
||||
sudo ls -lh "${LIB_DIR}"/pve1-auto.iso "${LIB_DIR}"/pve2-auto.iso
|
||||
echo "Next: ./04-install-nodes.sh"
|
||||
Reference in New Issue
Block a user