From cd94a855359f760b49ebd7dfbb9dd1a42c8e2143 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Tue, 25 Apr 2023 22:50:13 +0200 Subject: [PATCH] create data share directory when creating VM --- main.tf | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main.tf b/main.tf index 1808aad..51b0018 100644 --- a/main.tf +++ b/main.tf @@ -82,6 +82,20 @@ resource "libvirt_cloudinit_disk" "debian" { network_config = local.cloudinit_network_config } +resource "null_resource" "data_share" { + connection { + type = "ssh" + user = "root" + host = "atlas.hyp" + } + + provisioner "remote-exec" { + inline = [ + "${var.add_data_share} && mkdir --mode=og=rw /data/${local.domain_name}" + ] + } +} + resource "libvirt_domain" "debian" { name = local.domain_name memory = var.memory @@ -127,4 +141,8 @@ resource "libvirt_domain" "debian" { libvirt_cloudinit_disk.debian.id ] } + + depends_on = [ + null_resource.data_share + ] }