format and partition data disk

support only one data disk for now
This commit is contained in:
Pim Kunis 2023-04-07 17:42:54 +02:00
parent c80ec7a6f6
commit 8b6c42e1c5
3 changed files with 23 additions and 6 deletions

View file

@ -33,3 +33,19 @@ runcmd:
- dhclient -r - dhclient -r
- dhclient - dhclient
- locale-gen - locale-gen
%{ 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
mounts:
- ["data.1", "/mnt/data"]
%{ endif }

View file

@ -13,7 +13,8 @@ locals {
insecure_password = var.insecure_password, insecure_password = var.insecure_password,
use_host_cert = var.use_host_cert, use_host_cert = var.use_host_cert,
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,
data_disk = var.data_disk != null
}) })
} }
@ -79,9 +80,9 @@ resource "libvirt_domain" "debian" {
} }
dynamic "disk" { dynamic "disk" {
for_each = var.data_disks for_each = var.data_disk != null ? [1] : []
content { content {
volume_id = disk.value volume_id = var.data_disk
} }
} }

View file

@ -55,7 +55,7 @@ variable "ca_host" {
type = string type = string
} }
variable "data_disks" { variable "data_disk" {
type = list(string) type = string
default = [] default = null
} }