2024-08-04 16:16:53 +02:00
|
|
|
|
|
|
|
locals {
|
|
|
|
kernel = "/assets/fedora-coreos/fedora-coreos-${var.os_version}-live-kernel-x86_64"
|
|
|
|
initrd = "/assets/fedora-coreos/fedora-coreos-${var.os_version}-live-initramfs.x86_64.img"
|
|
|
|
rootfs = "${var.matchbox_http_endpoint}/assets/fedora-coreos/fedora-coreos-${var.os_version}-live-rootfs.x86_64.img"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# module "virtnode" {
|
|
|
|
# source = "../terraform-modules/coreos-agent"
|
|
|
|
#
|
|
|
|
# name = "virtnode"
|
|
|
|
# pool = "default"
|
|
|
|
# base_image = "http://matchbox.lab.cowley.tech:8080/assets/fedora-coreos/fedora-coreos-39.20231101.3.0-qemu.x86_64.qcow2"
|
|
|
|
# memory = 2048
|
|
|
|
# vcpu = 1
|
|
|
|
# disk_size = 30
|
|
|
|
#
|
|
|
|
# bridge = "br6"
|
|
|
|
# ignition = data.ignition_config.worker.rendered
|
|
|
|
# }
|
|
|
|
|
2025-04-16 09:46:17 +00:00
|
|
|
#resource "matchbox_profile" "worker" {
|
|
|
|
# name = "worker"
|
|
|
|
# kernel = local.kernel
|
|
|
|
# initrd = [
|
|
|
|
# "--name main ${local.initrd}"
|
|
|
|
# ]
|
|
|
|
# args = [
|
|
|
|
# "ip=dhcp",
|
|
|
|
# "initrd=main",
|
|
|
|
# "coreos.live.rootfs_url=${local.rootfs}",
|
|
|
|
# "coreos.inst.install_dev=/dev/vda",
|
|
|
|
# "coreos.inst.ignition_url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
|
|
|
|
# "console=tty0",
|
|
|
|
# "console=ttyS0",
|
|
|
|
# ]
|
|
|
|
# raw_ignition = data.ignition_config.worker.rendered
|
|
|
|
#}
|
2024-08-04 16:16:53 +02:00
|
|
|
|
|
|
|
resource "matchbox_profile" "nuc" {
|
|
|
|
name = "nuc"
|
|
|
|
kernel = local.kernel
|
|
|
|
initrd = [
|
|
|
|
"--name main ${local.initrd}"
|
|
|
|
]
|
|
|
|
args = [
|
|
|
|
"ip=dhcp",
|
|
|
|
"initrd=main",
|
|
|
|
"coreos.live.rootfs_url=${local.rootfs}",
|
|
|
|
"coreos.inst.install_dev=/dev/sda",
|
|
|
|
"coreos.inst.ignition_url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
|
|
|
|
"console=tty0",
|
|
|
|
"console=ttyS0",
|
|
|
|
]
|
|
|
|
raw_ignition = data.ignition_config.nuc.rendered
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "matchbox_group" "nuc" {
|
|
|
|
for_each = var.nucs
|
|
|
|
|
|
|
|
name = each.key
|
|
|
|
profile = matchbox_profile.nuc.name
|
|
|
|
selector = {
|
|
|
|
# mac = "c0:3f:d5:63:7b:3c"
|
|
|
|
mac = each.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-04-16 09:46:17 +00:00
|
|
|
#resource "matchbox_group" "slowworker" {
|
|
|
|
# for_each = var.slowworkers
|
|
|
|
#
|
|
|
|
# name = each.key
|
|
|
|
# profile = matchbox_profile.worker.name
|
|
|
|
# selector = {
|
|
|
|
# mac = each.value
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
#}
|
|
|
|
|
|
|
|
#resource "matchbox_group" "worker" {
|
|
|
|
# name = "worker"
|
|
|
|
# profile = matchbox_profile.worker.name
|
|
|
|
# selector = {
|
|
|
|
# mac = "52:54:00:c3:51:e8"
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
#}
|
2024-08-04 16:16:53 +02:00
|
|
|
|
|
|
|
data "ignition_user" "core" {
|
|
|
|
name = "core"
|
|
|
|
ssh_authorized_keys = [
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPTIgRUxUcj4K6E9xwwuxWyRaR4tkf57cgWkk5eWTnck ccowley@pinebook",
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK3jy6l2FSrkUoOVLGP4Spvz+X1sQbt5zY/CpWTRpzRi ccowley@lat5320ccowley.ubisoft.org",
|
|
|
|
var.ssh_authorized_key
|
|
|
|
]
|
|
|
|
}
|
2025-04-16 09:46:17 +00:00
|
|
|
#
|
|
|
|
#data "ignition_config" "worker" {
|
|
|
|
# users = [
|
|
|
|
# data.ignition_user.core.rendered
|
|
|
|
# ]
|
|
|
|
# systemd = [
|
|
|
|
# data.ignition_systemd_unit.qemu_ga.rendered,
|
|
|
|
# data.ignition_systemd_unit.k3s_install.rendered,
|
|
|
|
# data.ignition_systemd_unit.worker-images-clean-service.rendered,
|
|
|
|
# data.ignition_systemd_unit.worker-images-clean-timer.rendered
|
|
|
|
# ]
|
|
|
|
# files = [
|
|
|
|
# data.ignition_file.worker-options.rendered,
|
|
|
|
# data.ignition_file.k3s_agent_install_script.rendered,
|
|
|
|
# data.ignition_file.worker-images-clean.rendered
|
|
|
|
# ]
|
|
|
|
#}
|
2024-08-04 16:16:53 +02:00
|
|
|
data "ignition_config" "nuc" {
|
|
|
|
users = [
|
|
|
|
data.ignition_user.core.rendered
|
|
|
|
]
|
|
|
|
systemd = [
|
|
|
|
data.ignition_systemd_unit.kvm_install.rendered,
|
|
|
|
data.ignition_systemd_unit.k3s_install.rendered,
|
|
|
|
data.ignition_systemd_unit.worker-images-clean-service.rendered,
|
|
|
|
data.ignition_systemd_unit.worker-images-clean-timer.rendered
|
|
|
|
]
|
|
|
|
files = [
|
|
|
|
data.ignition_file.nuc-worker-options.rendered,
|
|
|
|
data.ignition_file.k3s_agent_install_script.rendered,
|
|
|
|
data.ignition_file.worker-images-clean.rendered
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
data "ignition_systemd_unit" "qemu_ga" {
|
|
|
|
name = "qemu-ga-install.service"
|
|
|
|
content = file("${path.module}/units/qemu-ga.service")
|
|
|
|
}
|
|
|
|
|
|
|
|
data "ignition_file" "k3s_agent_install_script" {
|
|
|
|
path = "/opt/k3s-agent-install.sh"
|
|
|
|
mode = 700
|
|
|
|
content {
|
|
|
|
content = templatefile(
|
|
|
|
"${path.module}/files/k3s-agent-install.sh",
|
|
|
|
{
|
|
|
|
"k3s_token" = var.k3s_agent_token
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data "ignition_systemd_unit" "k3s_install" {
|
|
|
|
name = "k3s-install.service"
|
|
|
|
depends_on = [
|
|
|
|
data.ignition_file.k3s_agent_install_script
|
|
|
|
]
|
|
|
|
content = file("${path.module}/units/k3s-install.service")
|
|
|
|
}
|
|
|
|
|
|
|
|
data "ignition_systemd_unit" "kvm_install" {
|
2025-04-16 09:46:17 +00:00
|
|
|
name = "kvm-install.service"
|
2024-08-04 16:16:53 +02:00
|
|
|
content = file("${path.module}/units/kvm-install.service")
|
|
|
|
}
|
|
|
|
|
|
|
|
data "ignition_file" "nuc-worker-options" {
|
|
|
|
path = "/etc/rancher/k3s/config.yaml"
|
|
|
|
content {
|
|
|
|
content = file("${path.module}/files/k3s-nuc-worker-config.yaml")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data "ignition_file" "worker-options" {
|
|
|
|
path = "/etc/rancher/k3s/config.yaml"
|
|
|
|
content {
|
|
|
|
content = file("${path.module}/files/k3s-worker-config.yaml")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data "ignition_file" "worker-images-clean" {
|
|
|
|
path = "/opt/k3s-image-clean.sh"
|
|
|
|
mode = 700
|
|
|
|
content {
|
|
|
|
content = file("${path.module}/files/k3s-clean-images.sh")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data "ignition_systemd_unit" "worker-images-clean-service" {
|
|
|
|
name = "clean-images.service"
|
|
|
|
depends_on = [
|
|
|
|
data.ignition_file.worker-images-clean
|
|
|
|
]
|
|
|
|
content = file("${path.module}/units/clean-images.service")
|
|
|
|
}
|
|
|
|
|
|
|
|
data "ignition_systemd_unit" "worker-images-clean-timer" {
|
|
|
|
name = "clean-images.timer"
|
|
|
|
depends_on = [
|
|
|
|
data.ignition_file.worker-images-clean,
|
|
|
|
data.ignition_systemd_unit.worker-images-clean-service,
|
|
|
|
]
|
|
|
|
content = file("${path.module}/units/clean-images.timer")
|
|
|
|
}
|