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
|
name = var.name
|
||||||
target = each.key
|
target = each.key
|
||||||
type = var.type
|
type = var.type
|
||||||
config = {
|
config = var.hypervisor_config
|
||||||
"parent" = var.hypervisor_parent
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "incus_network" "witness" {
|
resource "incus_network" "witness" {
|
||||||
@@ -21,9 +19,7 @@ resource "incus_network" "witness" {
|
|||||||
name = var.name
|
name = var.name
|
||||||
target = each.key
|
target = each.key
|
||||||
type = var.type
|
type = var.type
|
||||||
config = {
|
config = var.witness_config
|
||||||
"parent" = var.witness_parent
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "incus_network" "this" {
|
resource "incus_network" "this" {
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ variable "witnesses" {
|
|||||||
type = set(string)
|
type = set(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "hypervisor_parent" {
|
variable "hypervisor_config" {
|
||||||
type = string
|
type = map(string)
|
||||||
default = "br0"
|
default = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "witness_parent" {
|
variable "witness_config" {
|
||||||
type = string
|
type = map(string)
|
||||||
default = "dummy0"
|
default = {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
incus_networks = {
|
incus_networks = {
|
||||||
"main" = 0
|
"main" = {
|
||||||
|
type = "physical"
|
||||||
|
hypervisor_config = {
|
||||||
|
"parent" = "br0"
|
||||||
|
}
|
||||||
|
witness_config = {
|
||||||
|
"parent" = "dummy0"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ module "network" {
|
|||||||
source = "./modules/network"
|
source = "./modules/network"
|
||||||
for_each = var.incus_networks
|
for_each = var.incus_networks
|
||||||
name = each.key
|
name = each.key
|
||||||
|
type = each.value.type
|
||||||
hypervisors = toset(keys(var.incus_hypervisors))
|
hypervisors = toset(keys(var.incus_hypervisors))
|
||||||
witnesses = toset(keys(var.incus_witnesses))
|
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" {
|
variable "incus_networks" {
|
||||||
type = map(number)
|
type = map(object({
|
||||||
|
type = string
|
||||||
|
hypervisor_config = map(string)
|
||||||
|
witness_config = map(string)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "incus_storage_pools" {
|
variable "incus_storage_pools" {
|
||||||
|
|||||||
Reference in New Issue
Block a user