80 lines
1.4 KiB
HCL
80 lines
1.4 KiB
HCL
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 = concat([incus_profile.this.name], 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"
|
|
}
|
|
}
|
|
|
|
resource "incus_profile" "this" {
|
|
name = var.name
|
|
description = "Default profile for ${var.name}"
|
|
project = var.project
|
|
|
|
config = {
|
|
"limits.cpu" = var.cpu
|
|
"limits.memory" = var.memory
|
|
"boot.autostart" = false
|
|
"security.secureboot" = true
|
|
}
|
|
|
|
device {
|
|
name = "root"
|
|
type = "disk"
|
|
|
|
properties = {
|
|
"pool" = "default"
|
|
"path" = "/"
|
|
"size" = "16GiB"
|
|
}
|
|
}
|
|
}
|