Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions cloud-init.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions provision/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions provision/variables.tf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
variable "ipv6_prefix" {
}
28 changes: 26 additions & 2 deletions virt.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

<xsl:template match="/domain/features/acpi"/>
<xsl:template match="/domain/features/apic"/>

<xsl:template match="/domain/devices/controller[@type='ide']">
<controller type='scsi' model='virtio-scsi' index='0'/>
</xsl:template>

<xsl:template match="/domain/devices/disk[@device='cdrom']/target">
<target dev='sda' bus='scsi'/>
</xsl:template>

<xsl:template match="/domain/devices/disk[@device='cdrom']/address"/>

</xsl:stylesheet>
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" : ""
Expand Down