make domain name definition a function of the vm name

This commit is contained in:
Lukas Greve
2025-09-18 20:35:33 +02:00
parent 902420a3ea
commit 17a810d9c0
2 changed files with 9 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
resource "libvirt_network" "tf_libvirt_network" {
name = "${var.vm_name}-network"
mode = var.network_mode
domain = var.network_domain
domain = local.computed_network_domain
addresses = var.network_addresses
dns {

View File

@@ -73,12 +73,6 @@ variable "vcpu" {
default = 1
}
variable "network_name" {
description = "Name of the network"
type = string
default = "tf"
}
variable "network_mode" {
description = "Network mode (nat, none, route, open, bridge)"
type = string
@@ -86,9 +80,10 @@ variable "network_mode" {
}
variable "network_domain" {
description = "Domain name for the network"
description = "Domain name for the network (derived from vm_name)"
type = string
default = "tf.local"
# Default dynamically based on vm_name
default = ""
}
variable "network_addresses" {
@@ -137,4 +132,9 @@ variable "uefi_nvram_file_suffix" {
EOT
type = string
default = ""
}
# Computed variable for network domain (derived from vm_name)
locals {
computed_network_domain = var.network_domain != "" ? var.network_domain : "${var.vm_name}.local"
}