Make clone-and-register work

This commit is contained in:
stb 2024-07-27 10:18:41 +02:00
parent dd377c3ade
commit e6dc52d27e
4 changed files with 16 additions and 13 deletions

View file

@ -24,7 +24,8 @@ other KVM based virtualization solution.
The script `build-forgejorunner-template.sh` runs on a Proxmox cluster host. 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 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 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 It creates a template VM from the image, installing https://code.forgejo.org/forgejo/runner
and some helper scripts. and some helper scripts.

View file

@ -16,8 +16,8 @@ vm_name=template-forgejo-runner
vm_bridge=vmbr4 vm_bridge=vmbr4
vm_storage="local-zfs" vm_storage="local-zfs"
#ssh ${builder_host} sudo sh <${builder_script} ssh ${builder_host} sudo sh <${builder_script}
#scp ${builder_host}:${runner_image} . scp ${builder_host}:${runner_image} .
wget --output-document=forgejo-runner ${forgejo_runner_url} wget --output-document=forgejo-runner ${forgejo_runner_url}
wget -N https://git.hamburg.ccc.de/CCCHH/infrastructure-authorized-keys/raw/branch/trunk/authorized_keys wget -N https://git.hamburg.ccc.de/CCCHH/infrastructure-authorized-keys/raw/branch/trunk/authorized_keys

17
clone-and-register.sh Normal file → Executable file
View file

@ -4,14 +4,20 @@
# Clone the template VM and register the runner with Forgejo # Clone the template VM and register the runner with Forgejo
# #
if [ $# -ne 2 ]; then if [ $# -ne 3 ]; then
echo "usage: $0 vmid registration-token" echo "usage: $0 vmid name registration-token"
exit 64
fi fi
vm_id="$1" set -e
token="$2"
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} qm start ${vm_id}
while :; do while :; do
qm agent ${vm_id} ping && break qm agent ${vm_id} ping && break
@ -19,6 +25,7 @@ while :; do
sleep 10 sleep 10
done 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} -- sudo -iu forgejo-runner register-forgejo-runner "${token}"
qm guest exec ${vm_id} -- systemctl restart forgejo-runner qm guest exec ${vm_id} -- systemctl restart forgejo-runner

View file

@ -1,5 +0,0 @@
#!/bin/sh
#
# Clone the template VM and register the new VM as a Forgejo runner
#