114 lines
2.2 KiB
HCL
114 lines
2.2 KiB
HCL
# ------
|
|
# Locals
|
|
# ------
|
|
|
|
locals {
|
|
root_disk_size = "16GiB"
|
|
ext_disk_size = "16GiB"
|
|
network_cidr = "10.150.0.1/24"
|
|
|
|
master_count = 2
|
|
worker_count = 0
|
|
|
|
image = "ubuntu/26.04"
|
|
}
|
|
|
|
# ---------
|
|
# Resources
|
|
# ---------
|
|
|
|
resource "incus_project" "this" {
|
|
name = "home-infrastructure"
|
|
description = "An emulated home infrastructure stack."
|
|
}
|
|
|
|
resource "incus_image" "this" {
|
|
project = incus_project.this.name
|
|
|
|
source_image = {
|
|
remote = "images"
|
|
name = local.image
|
|
type = "virtual-machine"
|
|
}
|
|
}
|
|
|
|
resource "incus_profile" "this" {
|
|
name = "Default"
|
|
description = "The default profile applied to both masters and workers."
|
|
project = incus_project.this.name
|
|
|
|
depends_on = [incus_network.this]
|
|
|
|
config = {
|
|
"limits.cpu" = var.cpus
|
|
"limits.memory" = var.memory
|
|
"boot.autostart" = false
|
|
"security.secureboot" = false
|
|
}
|
|
|
|
device {
|
|
name = "root"
|
|
type = "disk"
|
|
|
|
properties = {
|
|
"pool" = "default"
|
|
"path" = "/"
|
|
"size" = local.root_disk_size
|
|
}
|
|
}
|
|
}
|
|
|
|
resource "incus_network" "this" {
|
|
name = "deskpi-cluster"
|
|
description = "An emulated network for the DeskPi Super6C cluster project."
|
|
project = incus_project.this.name
|
|
type = "bridge"
|
|
|
|
config = {
|
|
"ipv4.address" = local.network_cidr
|
|
"ipv4.nat" = true
|
|
}
|
|
}
|
|
|
|
module "master" {
|
|
source = "./modules/incus_vm"
|
|
count = local.master_count
|
|
|
|
name = "master-${count.index}"
|
|
project = incus_project.this.name
|
|
image = incus_image.this.fingerprint
|
|
profiles = [incus_profile.this.name]
|
|
network = incus_network.this.name
|
|
ipv4_address = cidrhost(local.network_cidr, 2 + (2 * count.index))
|
|
}
|
|
|
|
module "worker" {
|
|
source = "./modules/incus_vm"
|
|
count = local.master_count
|
|
|
|
name = "worker-${count.index}"
|
|
project = incus_project.this.name
|
|
image = incus_image.this.fingerprint
|
|
profiles = [incus_profile.this.name]
|
|
network = incus_network.this.name
|
|
ipv4_address = cidrhost(local.network_cidr, 3 + (2 * count.index))
|
|
}
|
|
|
|
# ---------
|
|
# Terraform
|
|
# ---------
|
|
|
|
terraform {
|
|
required_version = "~> 1.12"
|
|
|
|
required_providers {
|
|
incus = {
|
|
source = "lxc/incus"
|
|
version = "~> 1.1"
|
|
}
|
|
}
|
|
}
|
|
|
|
provider "incus" {
|
|
}
|