try to fix data share remote exec

This commit is contained in:
Pim Kunis 2023-05-08 09:18:13 +02:00
parent 8c9120df6d
commit 88e3def563
3 changed files with 6 additions and 6 deletions

View file

@ -40,7 +40,7 @@ runcmd:
- dhclient - dhclient
- locale-gen - locale-gen
%{ if data_share != null } %{ if data_share != "" }
mounts: mounts:
- ["data", "${data_share}", "9p", "trans=virtio,rw", "0", "0"] - ["data", "${data_share}", "9p", "trans=virtio,rw", "0", "0"]
%{ endif } %{ endif }

View file

@ -15,7 +15,7 @@ locals {
host_cert = trimspace(null_resource.cert.triggers["cert"]), host_cert = trimspace(null_resource.cert.triggers["cert"]),
private_key = tls_private_key.debian.private_key_openssh, private_key = tls_private_key.debian.private_key_openssh,
fixed_dns = var.fixed_dns fixed_dns = var.fixed_dns
data_share = var.data_share data_share = var.data_share
}) })
cloudinit_network_config = templatefile("${path.module}/files/network_config.cfg.tftpl", { cloudinit_network_config = templatefile("${path.module}/files/network_config.cfg.tftpl", {
fixed_address = var.fixed_address fixed_address = var.fixed_address
@ -90,7 +90,7 @@ resource "null_resource" "data_share" {
provisioner "remote-exec" { provisioner "remote-exec" {
inline = [ inline = [
"if [ \"${var.data_share}\" != \"null\"; then mkdir -p --mode=og=rwx /data/${local.domain_name}; fi" "if [ \"${var.data_share}\" != \"\"; then mkdir -p --mode=og=rwx /data/${local.domain_name}; fi"
] ]
} }
} }
@ -106,7 +106,7 @@ resource "libvirt_domain" "debian" {
} }
dynamic "filesystem" { dynamic "filesystem" {
for_each = var.data_share != null ? [1] : [] for_each = var.data_share != "" ? [1] : []
content { content {
source = "/data/${local.domain_name}" source = "/data/${local.domain_name}"

View file

@ -103,8 +103,8 @@ variable "fixed_dns" {
variable "data_share" { variable "data_share" {
type = string type = string
default = null default = ""
description = "Location for the data share on the guest OS." description = "Location for the data share on the guest OS. Leave empty to disable."
} }
variable "hypervisor_host" { variable "hypervisor_host" {