92 lines
1.6 KiB
HCL
92 lines
1.6 KiB
HCL
# ------
|
|
# Locals
|
|
# ------
|
|
|
|
locals {
|
|
root_disk_size = "16GiB"
|
|
ext_disk_size = "16GiB"
|
|
network_cidr = "10.150.0.1/24"
|
|
|
|
master_count = 3
|
|
worker_count = 0
|
|
|
|
image = "ubuntu/26.04"
|
|
}
|
|
|
|
# ---------
|
|
# Resources
|
|
# ---------
|
|
|
|
resource "incus_project" "this" {
|
|
name = "homelab"
|
|
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_network" "this" {
|
|
name = "homelab"
|
|
description = "An emulated home infrastructure stack."
|
|
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
|
|
cpu = 2
|
|
memory = "2GiB"
|
|
|
|
network = incus_network.this.name
|
|
ipv4_address = cidrhost(local.network_cidr, 2 + (2 * count.index))
|
|
}
|
|
|
|
module "worker" {
|
|
source = "./modules/incus_vm"
|
|
count = local.worker_count
|
|
|
|
name = "worker-${count.index}"
|
|
project = incus_project.this.name
|
|
image = incus_image.this.fingerprint
|
|
cpu = 2
|
|
memory = "2GiB"
|
|
|
|
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" {
|
|
}
|