Refactor network module to accept free-form config maps
Replace hypervisor_parent/witness_parent strings with hypervisor_config and witness_config map(string) variables, matching the pattern already used by the storage module. incus_networks in the root module is updated from map(number) to map(object) carrying type and the two config maps. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,9 +11,7 @@ resource "incus_network" "hypervisor" {
|
||||
name = var.name
|
||||
target = each.key
|
||||
type = var.type
|
||||
config = {
|
||||
"parent" = var.hypervisor_parent
|
||||
}
|
||||
config = var.hypervisor_config
|
||||
}
|
||||
|
||||
resource "incus_network" "witness" {
|
||||
@@ -21,9 +19,7 @@ resource "incus_network" "witness" {
|
||||
name = var.name
|
||||
target = each.key
|
||||
type = var.type
|
||||
config = {
|
||||
"parent" = var.witness_parent
|
||||
}
|
||||
config = var.witness_config
|
||||
}
|
||||
|
||||
resource "incus_network" "this" {
|
||||
|
||||
@@ -15,12 +15,12 @@ variable "witnesses" {
|
||||
type = set(string)
|
||||
}
|
||||
|
||||
variable "hypervisor_parent" {
|
||||
type = string
|
||||
default = "br0"
|
||||
variable "hypervisor_config" {
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "witness_parent" {
|
||||
type = string
|
||||
default = "dummy0"
|
||||
variable "witness_config" {
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
incus_networks = {
|
||||
"main" = 0
|
||||
"main" = {
|
||||
type = "physical"
|
||||
hypervisor_config = {
|
||||
"parent" = "br0"
|
||||
}
|
||||
witness_config = {
|
||||
"parent" = "dummy0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ module "network" {
|
||||
source = "./modules/network"
|
||||
for_each = var.incus_networks
|
||||
name = each.key
|
||||
type = each.value.type
|
||||
hypervisors = toset(keys(var.incus_hypervisors))
|
||||
witnesses = toset(keys(var.incus_witnesses))
|
||||
hypervisor_config = each.value.hypervisor_config
|
||||
witness_config = each.value.witness_config
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@ variable "incus_token" {
|
||||
}
|
||||
|
||||
variable "incus_networks" {
|
||||
type = map(number)
|
||||
type = map(object({
|
||||
type = string
|
||||
hypervisor_config = map(string)
|
||||
witness_config = map(string)
|
||||
}))
|
||||
}
|
||||
|
||||
variable "incus_storage_pools" {
|
||||
|
||||
Reference in New Issue
Block a user