๐Ÿ“ฆ fffonion / kvm-github-actions-runner

๐Ÿ“„ virt.tf ยท 64 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64resource "libvirt_volume" "master" {
  name = "${var.name}-master.qcow2"
  #base_volume_id = libvirt_volume.base_volume.id
  base_volume_name = "runner-ubuntu-24.04-${local.image_version}.qcow2"
  pool             = "kong"
}


# Define KVM domain to create
resource "libvirt_domain" "test" {
  name   = "${var.name}-runner"
  memory = var.memory
  vcpu   = var.cpu

  cpu {
    mode = "host-passthrough"
  }

  cloudinit = libvirt_cloudinit_disk.commoninit.id

  disk {
    volume_id = libvirt_volume.master.id
  }

  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") : ""
  }

  machine = var.arm64 ? "virt" : "pc"
  nvram {
    file     = var.arm64 ? "/usr/share/AAVMF/AAVMF_CODE.fd" : ""
    template = var.arm64 ? "flash1.img" : ""
  }

  # IMPORTANT: this is a known bug on cloud images, since they expect a console
  # we need to pass it
  # https://bugs.launchpad.net/cloud-images/+bug/1573095
  console {
    type        = "pty"
    target_port = "0"
    target_type = "serial"
  }

  console {
    type        = "pty"
    target_type = "virtio"
    target_port = "1"
  }

  graphics {
    type        = "spice"
    listen_type = "address"
    autoport    = true
  }


  network_interface {
    network_name = "kong" # List networks with virsh net-list
    hostname     = "${var.name}-runner"
  }
}