diff --git a/main.tf b/main.tf index 4be968d..6383eae 100644 --- a/main.tf +++ b/main.tf @@ -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 diff --git a/variables.tf b/variables.tf index 2c2ce68..7fe7cbb 100644 --- a/variables.tf +++ b/variables.tf @@ -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