feat: modularise incus vm

This commit is contained in:
2026-06-26 23:30:27 +01:00
parent 687e061b93
commit fba3827961
4 changed files with 119 additions and 87 deletions
+55
View File
@@ -0,0 +1,55 @@
terraform {
required_providers {
incus = {
source = "lxc/incus"
version = ">= 1.1.1"
}
}
}
resource "incus_instance" "this" {
name = var.name
description = var.description
project = var.project
type = "virtual-machine"
image = var.image
profiles = var.profiles
wait_for {
type = "agent"
}
device {
name = "eth0"
type = "nic"
properties = {
"network" = var.network
"ipv4.address" = var.ipv4_address
}
}
device {
name = "ext"
type = "disk"
properties = {
"pool" = "default"
"source" = incus_storage_volume.this.name
}
}
}
resource "incus_storage_volume" "this" {
name = "${var.name}-ext"
description = "External disk for ${var.name}"
pool = "default"
project = var.project
content_type = "block"
config = {
"size" = "16GiB"
}
}
View File
+42
View File
@@ -0,0 +1,42 @@
variable "name" {
type = string
description = "The name for this instance."
nullable = false
}
variable "description" {
type = string
description = "The description for this instance."
nullable = false
default = ""
}
variable "project" {
type = string
description = "The project this instance belongs to."
nullable = true
}
variable "image" {
type = string
description = "The image for this instance."
nullable = false
}
variable "profiles" {
type = list(string)
description = "The profiles for this instance."
nullable = false
}
variable "network" {
type = string
description = "The network for this instance."
nullable = false
}
variable "ipv4_address" {
type = string
description = "The IPv4 address for this instance."
nullable = false
}