add ability to change domain name

This commit is contained in:
Pim Kunis 2023-04-12 15:15:45 +02:00
parent b7272412b4
commit 7234433575
2 changed files with 9 additions and 3 deletions

View file

@ -19,6 +19,7 @@ locals {
cloudinit_network_config = templatefile("${path.module}/files/network_config.cfg.tftpl", {
fixed_address = var.fixed_address
})
domain_name = coalesce(var.domain_name, var.name)
}
resource "tls_private_key" "debian" {
@ -52,7 +53,7 @@ resource "null_resource" "cert" {
}
resource "libvirt_volume" "debian" {
name = "${var.name}.iso"
name = "${local.domain_name}.iso"
pool = var.disk_pool
size = var.disk_size
base_volume_name = var.disk_base
@ -66,14 +67,14 @@ resource "libvirt_volume" "debian" {
}
resource "libvirt_cloudinit_disk" "debian" {
name = "${var.name}.iso"
name = "${local.domain_name}.iso"
pool = var.cloudinit_pool
user_data = local.cloudinit_user_data
network_config = local.cloudinit_network_config
}
resource "libvirt_domain" "debian" {
name = var.name
name = local.domain_name
memory = var.memory
vcpu = 4
autostart = true

View file

@ -2,6 +2,11 @@ variable "name" {
type = string
}
variable "domain_name" {
type = string
default = null
}
variable "disk_size" {
type = number
default = 1024 * 1024 * 1024 * 15