ability to specify data share directory
This commit is contained in:
parent
89d7ad537f
commit
a219ce0b2d
3 changed files with 9 additions and 9 deletions
|
@ -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 != "" }
|
||||
|
|
6
main.tf
6
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}"
|
||||
|
|
|
@ -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" {
|
||||
|
|
Reference in a new issue