format and partition data disk
support only one data disk for now
This commit is contained in:
parent
c80ec7a6f6
commit
8b6c42e1c5
3 changed files with 23 additions and 6 deletions
|
@ -33,3 +33,19 @@ runcmd:
|
|||
- dhclient -r
|
||||
- dhclient
|
||||
- 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 }
|
||||
|
|
7
main.tf
7
main.tf
|
@ -13,7 +13,8 @@ locals {
|
|||
insecure_password = var.insecure_password,
|
||||
use_host_cert = var.use_host_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" {
|
||||
for_each = var.data_disks
|
||||
for_each = var.data_disk != null ? [1] : []
|
||||
content {
|
||||
volume_id = disk.value
|
||||
volume_id = var.data_disk
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ variable "ca_host" {
|
|||
type = string
|
||||
}
|
||||
|
||||
variable "data_disks" {
|
||||
type = list(string)
|
||||
default = []
|
||||
variable "data_disk" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
|
Reference in a new issue