133 lines
3.5 KiB
HCL
133 lines
3.5 KiB
HCL
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
|
|
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
|
|
]
|
|
}
|
|
|
|
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" {
|
|
name = "kvm-install.service"
|
|
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")
|
|
}
|