diff --git a/incus/modules/network/main.tf b/incus/modules/network/main.tf index 6e77062..8a9fc2b 100644 --- a/incus/modules/network/main.tf +++ b/incus/modules/network/main.tf @@ -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" { diff --git a/incus/modules/network/variables.tf b/incus/modules/network/variables.tf index a5d5b40..36aebc4 100644 --- a/incus/modules/network/variables.tf +++ b/incus/modules/network/variables.tf @@ -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 = {} } diff --git a/incus/network.auto.tfvars b/incus/network.auto.tfvars index 8c529b3..55df2f7 100644 --- a/incus/network.auto.tfvars +++ b/incus/network.auto.tfvars @@ -1,3 +1,11 @@ incus_networks = { - "main" = 0 + "main" = { + type = "physical" + hypervisor_config = { + "parent" = "br0" + } + witness_config = { + "parent" = "dummy0" + } + } } diff --git a/incus/network.tf b/incus/network.tf index c14aaf6..b9bde5e 100644 --- a/incus/network.tf +++ b/incus/network.tf @@ -1,8 +1,11 @@ module "network" { - source = "./modules/network" - for_each = var.incus_networks - name = each.key - hypervisors = toset(keys(var.incus_hypervisors)) - witnesses = toset(keys(var.incus_witnesses)) + 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 } diff --git a/incus/variables.tf b/incus/variables.tf index 6aa0517..eb18cc1 100644 --- a/incus/variables.tf +++ b/incus/variables.tf @@ -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" {