diff --git a/files/cloud_init.cfg.tftpl b/files/cloud_init.cfg.tftpl index 3a1f2b7..304154b 100644 --- a/files/cloud_init.cfg.tftpl +++ b/files/cloud_init.cfg.tftpl @@ -40,9 +40,9 @@ runcmd: - dhclient - locale-gen -%{ if add_data_share } +%{ if data_share != null } mounts: -- ["data", "/mnt/data", "9p", "trans=virtio,rw", "0", "0"] +- ["data", "${data_share}", "9p", "trans=virtio,rw", "0", "0"] %{ endif } %{ if fixed_dns != "" } diff --git a/main.tf b/main.tf index 078a26e..7523c3a 100644 --- a/main.tf +++ b/main.tf @@ -15,7 +15,7 @@ locals { host_cert = trimspace(null_resource.cert.triggers["cert"]), private_key = tls_private_key.debian.private_key_openssh, fixed_dns = var.fixed_dns - add_data_share = var.add_data_share + data_share = var.data_share }) cloudinit_network_config = templatefile("${path.module}/files/network_config.cfg.tftpl", { fixed_address = var.fixed_address @@ -90,7 +90,7 @@ resource "null_resource" "data_share" { provisioner "remote-exec" { inline = [ - "${var.add_data_share} && mkdir -p --mode=og=rwx /data/${local.domain_name}" + "${var.data_share} != null && mkdir -p --mode=og=rwx /data/${local.domain_name}" ] } } @@ -106,7 +106,7 @@ resource "libvirt_domain" "debian" { } dynamic "filesystem" { - for_each = var.add_data_share ? [1] : [] + for_each = var.data_share != null ? [1] : [] content { source = "/data/${local.domain_name}" diff --git a/variables.tf b/variables.tf index be8d7b2..dbdc56c 100644 --- a/variables.tf +++ b/variables.tf @@ -101,10 +101,10 @@ variable "fixed_dns" { description = "Fixed DNS server the machine should have." } -variable "add_data_share" { - type = bool - default = true - description = "Whether to share /data with the guest OS." +variable "data_share" { + type = string + default = null + description = "Location for the data share on the guest OS." } variable "hypervisor_host" {