Add reusable storage pool module with lvmcluster san pool
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
32
incus/modules/storage/main.tf
Normal file
32
incus/modules/storage/main.tf
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
incus = {
|
||||||
|
source = "lxc/incus"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "incus_storage_pool" "hypervisor" {
|
||||||
|
for_each = var.hypervisors
|
||||||
|
name = var.name
|
||||||
|
driver = var.driver
|
||||||
|
target = each.key
|
||||||
|
config = var.hypervisor_config
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "incus_storage_pool" "witness" {
|
||||||
|
for_each = var.witnesses
|
||||||
|
name = var.name
|
||||||
|
driver = var.driver
|
||||||
|
target = each.key
|
||||||
|
config = var.witness_config
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "incus_storage_pool" "this" {
|
||||||
|
depends_on = [
|
||||||
|
incus_storage_pool.hypervisor,
|
||||||
|
incus_storage_pool.witness,
|
||||||
|
]
|
||||||
|
name = var.name
|
||||||
|
driver = var.driver
|
||||||
|
}
|
||||||
7
incus/modules/storage/outputs.tf
Normal file
7
incus/modules/storage/outputs.tf
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
output "name" {
|
||||||
|
value = incus_storage_pool.this.name
|
||||||
|
}
|
||||||
|
|
||||||
|
output "driver" {
|
||||||
|
value = incus_storage_pool.this.driver
|
||||||
|
}
|
||||||
25
incus/modules/storage/variables.tf
Normal file
25
incus/modules/storage/variables.tf
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
variable "name" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "driver" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "hypervisors" {
|
||||||
|
type = set(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "witnesses" {
|
||||||
|
type = set(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "hypervisor_config" {
|
||||||
|
type = map(string)
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "witness_config" {
|
||||||
|
type = map(string)
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
7
incus/storage.auto.tfvars
Normal file
7
incus/storage.auto.tfvars
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
incus_storage_pools = {
|
||||||
|
"san" = {
|
||||||
|
driver = "lvmcluster"
|
||||||
|
hypervisor_config = { "lvm.vg_name" = "nucVG" }
|
||||||
|
witness_config = { "lvm.vg_name" = "dummyVG" }
|
||||||
|
}
|
||||||
|
}
|
||||||
10
incus/storage.tf
Normal file
10
incus/storage.tf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
module "storage" {
|
||||||
|
source = "./modules/storage"
|
||||||
|
for_each = var.incus_storage_pools
|
||||||
|
name = each.key
|
||||||
|
driver = each.value.driver
|
||||||
|
hypervisors = toset(keys(var.incus_hypervisors))
|
||||||
|
witnesses = toset(keys(var.incus_witnesses))
|
||||||
|
hypervisor_config = each.value.hypervisor_config
|
||||||
|
witness_config = each.value.witness_config
|
||||||
|
}
|
||||||
@@ -15,3 +15,11 @@ variable "incus_token" {
|
|||||||
variable "incus_networks" {
|
variable "incus_networks" {
|
||||||
type = map(number)
|
type = map(number)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "incus_storage_pools" {
|
||||||
|
type = map(object({
|
||||||
|
driver = string
|
||||||
|
hypervisor_config = map(string)
|
||||||
|
witness_config = map(string)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user