reintroduce data disks

This commit is contained in:
Pim Kunis 2023-06-08 23:05:04 +02:00
parent 9f3fab470d
commit 49720ab12a
3 changed files with 36 additions and 1 deletions

View file

@ -40,10 +40,30 @@ runcmd:
- dhclient - dhclient
- locale-gen - locale-gen
%{ if data_share != "" } %{ if data_disk }
device_aliases:
data: /dev/vdb
disk_setup:
data:
table_type: 'gpt'
layout: true
overwrite: false
fs_setup:
- label: 'data'
filesystem: 'ext4'
device: data.1
overwrite: false
%{ endif }
%{ if data_disk || data_share }
mounts: mounts:
%{ if data_disk != "" }
- ["data.1", "/mnt/data"]
%{ endif }
%{ if data_share != "" }
- ["data", "${data_share}", "9p", "trans=virtio,rw", "0", "0"] - ["data", "${data_share}", "9p", "trans=virtio,rw", "0", "0"]
%{ endif } %{ endif }
%{ endif }
%{ if fixed_dns != "" } %{ if fixed_dns != "" }
manage_resolv_conf: true manage_resolv_conf: true

9
debian/main.tf vendored
View file

@ -21,6 +21,7 @@ locals {
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
data_disk = var.data_disk
}) })
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
@ -125,6 +126,14 @@ resource "libvirt_domain" "debian" {
} }
} }
dynamic "disk" {
for_each = var.data_disk != null ? [1] : []
content {
volume_id = var.data_disk
}
}
network_interface { network_interface {
bridge = local.bridge_name bridge = local.bridge_name
hostname = var.name hostname = var.name

6
debian/variables.tf vendored
View file

@ -85,3 +85,9 @@ variable "data_share" {
variable "hypervisor_host" { variable "hypervisor_host" {
type = string type = string
} }
variable "data_disk" {
type = string
default = ""
description = "Identifier of the machine's persistent data disk."
}