Install a one-shot service to initialize hostid

This commit is contained in:
Stefan Bethke 2026-03-31 19:55:02 +02:00
commit 7ebf94cc23
3 changed files with 28 additions and 2 deletions

View file

@ -9,12 +9,13 @@
: "${STORAGE:=local-zfs}"
: "${OS:=debian-13}"
: "${NAME:=chaos-${OS}-tmpl-$(date -u +%Y-%m-%d)}"
: "${BRIDGE:=vmbr0,tag=208}"
: "${BRIDGE:=vmbr0,tag=2}"
: "${AUTHORIZED_KEYS_URL:=https://git.hamburg.ccc.de/CCCHH/infrastructure-authorized-keys/raw/branch/trunk/authorized_keys}"
set -eE
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
here="$(pwd)"
tempfolder=$(mktemp -d /tmp/cloudinit-XXXXX)
pushd $tempfolder
@ -44,7 +45,11 @@ virt-customize -a disk.raw \
--uninstall openipmi \
--run-command 'systemctl enable qemu-guest-agent' \
--run-command 'systemctl enable fstrim.timer' \
--run-command 'echo -n >/etc/machine-id'
--run-command 'echo -n >/etc/machine-id' \
--copy-in ${here}/initialize-host-id:/usr/local/sbin \
--run-command 'chmod +x /usr/local/sbin/initialize-host-id' \
--copy-in ${here}/initialize-host-id.service:/etc/systemd/system \
--run-command 'systemctl enable initialize-host-id.service'
qm destroy ${VMID} || true
qm create ${VMID} --name "creating-vm" --memory 2048 --net0 virtio,bridge=${BRIDGE}