From e6dc52d27ef4ea1ac353f367fd337b083d8fc81c Mon Sep 17 00:00:00 2001 From: stb Date: Sat, 27 Jul 2024 10:18:41 +0200 Subject: [PATCH] Make clone-and-register work --- README.md | 3 ++- build-forgejorunner-template.sh | 4 ++-- clone-and-register.sh | 17 ++++++++++++----- clone-forgejo-runner.sh | 5 ----- 4 files changed, 16 insertions(+), 13 deletions(-) mode change 100644 => 100755 clone-and-register.sh delete mode 100644 clone-forgejo-runner.sh diff --git a/README.md b/README.md index f030af8..a2290b4 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ other KVM based virtualization solution. The script `build-forgejorunner-template.sh` runs on a Proxmox cluster host. It runs the build script via SSH on a builder VM (that has nested virtualization enabled), in case of CCCHH a Debian 12 install. It then copies the resulting VM to the -Proxmox host. +Proxmox host. **Note**: at the time of this writing, the builder VM needs at +least 16 cores to satisfy the KVMn config for the VM being built. It creates a template VM from the image, installing https://code.forgejo.org/forgejo/runner and some helper scripts. diff --git a/build-forgejorunner-template.sh b/build-forgejorunner-template.sh index 04e1cd4..3a83934 100755 --- a/build-forgejorunner-template.sh +++ b/build-forgejorunner-template.sh @@ -16,8 +16,8 @@ vm_name=template-forgejo-runner vm_bridge=vmbr4 vm_storage="local-zfs" -#ssh ${builder_host} sudo sh <${builder_script} -#scp ${builder_host}:${runner_image} . +ssh ${builder_host} sudo sh <${builder_script} +scp ${builder_host}:${runner_image} . wget --output-document=forgejo-runner ${forgejo_runner_url} wget -N https://git.hamburg.ccc.de/CCCHH/infrastructure-authorized-keys/raw/branch/trunk/authorized_keys diff --git a/clone-and-register.sh b/clone-and-register.sh old mode 100644 new mode 100755 index 289c499..6ae0ec3 --- a/clone-and-register.sh +++ b/clone-and-register.sh @@ -4,14 +4,20 @@ # Clone the template VM and register the runner with Forgejo # -if [ $# -ne 2 ]; then - echo "usage: $0 vmid registration-token" +if [ $# -ne 3 ]; then + echo "usage: $0 vmid name registration-token" + exit 64 fi -vm_id="$1" -token="$2" +set -e + +vm_id="$1" +vm_name="$2" +token="$3" + +qm clone 9042 ${vm_id} --full true --name "${vm_name}" +qm set ${vm_id} --ipconfig0 ip=172.31.17.203/25,gw=172.31.17.129 -qm clone 9042 ${vm_id} qm start ${vm_id} while :; do qm agent ${vm_id} ping && break @@ -19,6 +25,7 @@ while :; do sleep 10 done +echo "VM ${vm_id} started, trying to register runner..." qm guest exec ${vm_id} -- sudo -iu forgejo-runner register-forgejo-runner "${token}" qm guest exec ${vm_id} -- systemctl restart forgejo-runner diff --git a/clone-forgejo-runner.sh b/clone-forgejo-runner.sh deleted file mode 100644 index 7182a28..0000000 --- a/clone-forgejo-runner.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# -# Clone the template VM and register the new VM as a Forgejo runner -#