From 770feba8f85206e65bbd17b354bfe099d0e349bb Mon Sep 17 00:00:00 2001 From: Water-Melon Date: Fri, 30 Jan 2026 00:56:58 +0000 Subject: [PATCH] changes for provisioning a runner VM to run CI jobs --- cloud-init.sh.tmpl | 25 +++++++++++++++++++++---- provision/main.tf | 4 ++-- provision/variables.tf | 2 -- virt.tf | 28 ++++++++++++++++++++++++++-- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/cloud-init.sh.tmpl b/cloud-init.sh.tmpl index d72ca1d..ca96166 100644 --- a/cloud-init.sh.tmpl +++ b/cloud-init.sh.tmpl @@ -144,9 +144,21 @@ cd # goto my home mkdir actions-runner && cd actions-runner ARCH=$(arch) -if [[ $ARCH == "x86_64" ]]; then ARCH=x64 -else ARCH=arm64 -fi +case $ARCH in + x86_64) + ARCH="x64" + ;; + aarch64) + ARCH="arm64" + ;; + s390x) + ARCH="s390x" + ;; + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; +esac cat << 'EOF' > start.sh #!/bin/bash @@ -168,7 +180,11 @@ send_metrics jobs.repo send_metrics jobs.duration \$job_duration_ms "ms|@1" EOF -curl -o actions-runner-linux-$${ARCH}-${RUNNER_VER}.tar.gz -L https://github.com/actions/runner/releases/download/v${RUNNER_VER}/actions-runner-linux-$${ARCH}-${RUNNER_VER}.tar.gz +if [[ "$ARCH" == "s390x" ]]; then + curl -o actions-runner-linux-$${ARCH}-${RUNNER_VER}.tar.gz -L https://github.com/canonical/github-actions-runner/releases/download/v${RUNNER_VER}/actions-runner-linux-$${ARCH}-${RUNNER_VER}.tar.gz +else + curl -o actions-runner-linux-$${ARCH}-${RUNNER_VER}.tar.gz -L https://github.com/actions/runner/releases/download/v${RUNNER_VER}/actions-runner-linux-$${ARCH}-${RUNNER_VER}.tar.gz +fi tar xzf ./actions-runner-linux-$${ARCH}-${RUNNER_VER}.tar.gz @@ -233,6 +249,7 @@ send_metrics runner.provision_duration $provision_duration_ms "ms|@1" IFS=$'\r\n' export ACTIONS_RUNNER_HOOK_JOB_STARTED=/home/ubuntu/actions-runner/start.sh export ACTIONS_RUNNER_HOOK_JOB_COMPLETED=/home/ubuntu/actions-runner/stop.sh +export ACTIONS_RUNNER_DISABLE_UPDATE=true ./run.sh | grep -vE "^[ \t|/_\\()',\.\-]*$"| grep -vF 'Self-hosted runner registration' | while read line; do echo $line if echo $line | grep -q "Running job: "; then diff --git a/provision/main.tf b/provision/main.tf index 116018d..0b2d4ba 100644 --- a/provision/main.tf +++ b/provision/main.tf @@ -12,7 +12,7 @@ provider "libvirt" { } resource "libvirt_volume" "ubuntu_2404_base_volumes" { - for_each = toset([local.image_version, local.previous_image_version]) + for_each = toset([local.image_version]) name = "runner-ubuntu-24.04-${each.key}.qcow2" source = "/root/ubuntu-24.04-${each.key}" format = "qcow2" @@ -48,7 +48,7 @@ resource "libvirt_network" "kong" { } } - addresses = ["10.1.0.0/24", "${var.ipv6_prefix}:1001::/96"] + addresses = ["10.1.0.0/24"] autostart = true diff --git a/provision/variables.tf b/provision/variables.tf index b06a25d..e69de29 100644 --- a/provision/variables.tf +++ b/provision/variables.tf @@ -1,2 +0,0 @@ -variable "ipv6_prefix" { -} diff --git a/virt.tf b/virt.tf index 9dc7f85..ae205f7 100644 --- a/virt.tf +++ b/virt.tf @@ -25,10 +25,34 @@ resource "libvirt_domain" "test" { xml { # patch to use sata controller to compat in arm64 # https://github.com/dmacvicar/terraform-provider-libvirt/issues/885 - xslt = var.arm64 ? file("patch-cdrom-sata.xsl") : "" + xslt = <<-EOT + + + + + + + + + + + + + + + + + + + + + + + + EOT } - machine = var.arm64 ? "virt" : "pc" + machine = var.arm64 ? "virt" : "s390-ccw-virtio" nvram { file = var.arm64 ? "/usr/share/AAVMF/AAVMF_CODE.fd" : "" template = var.arm64 ? "flash1.img" : ""