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
|
- dhclient
|
||||||
- locale-gen
|
- locale-gen
|
||||||
|
|
||||||
%{ if add_data_share }
|
%{ if data_share != null }
|
||||||
mounts:
|
mounts:
|
||||||
- ["data", "/mnt/data", "9p", "trans=virtio,rw", "0", "0"]
|
- ["data", "${data_share}", "9p", "trans=virtio,rw", "0", "0"]
|
||||||
%{ endif }
|
%{ endif }
|
||||||
|
|
||||||
%{ if fixed_dns != "" }
|
%{ if fixed_dns != "" }
|
||||||
|
|
6
main.tf
6
main.tf
|
@ -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
|
||||||
add_data_share = var.add_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 = [
|
||||||
"${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" {
|
dynamic "filesystem" {
|
||||||
for_each = var.add_data_share ? [1] : []
|
for_each = var.data_share != null ? [1] : []
|
||||||
|
|
||||||
content {
|
content {
|
||||||
source = "/data/${local.domain_name}"
|
source = "/data/${local.domain_name}"
|
||||||
|
|
|
@ -101,10 +101,10 @@ variable "fixed_dns" {
|
||||||
description = "Fixed DNS server the machine should have."
|
description = "Fixed DNS server the machine should have."
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "add_data_share" {
|
variable "data_share" {
|
||||||
type = bool
|
type = string
|
||||||
default = true
|
default = null
|
||||||
description = "Whether to share /data with the guest OS."
|
description = "Location for the data share on the guest OS."
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "hypervisor_host" {
|
variable "hypervisor_host" {
|
||||||
|
|
Reference in a new issue