create data share directory when creating VM

This commit is contained in:
Pim Kunis 2023-04-25 22:50:13 +02:00
parent 308e572471
commit cd94a85535

18
main.tf
View file

@ -82,6 +82,20 @@ resource "libvirt_cloudinit_disk" "debian" {
network_config = local.cloudinit_network_config 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" { resource "libvirt_domain" "debian" {
name = local.domain_name name = local.domain_name
memory = var.memory memory = var.memory
@ -127,4 +141,8 @@ resource "libvirt_domain" "debian" {
libvirt_cloudinit_disk.debian.id libvirt_cloudinit_disk.debian.id
] ]
} }
depends_on = [
null_resource.data_share
]
} }