add ability to change disk size
This commit is contained in:
@@ -16,6 +16,18 @@ variable "pool_path" {
|
|||||||
default = "/opt/tf_tmp_storage"
|
default = "/opt/tf_tmp_storage"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "disk_size_gb" {
|
||||||
|
description = "Disk size in GB"
|
||||||
|
type = number
|
||||||
|
default = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "disk_size_bytes" {
|
||||||
|
description = "Disk size in bytes"
|
||||||
|
type = number
|
||||||
|
default = 20 * 1024 * 1024 * 1024
|
||||||
|
}
|
||||||
|
|
||||||
variable "instance_count" {
|
variable "instance_count" {
|
||||||
description = "Number of instances to create"
|
description = "Number of instances to create"
|
||||||
type = number
|
type = number
|
||||||
|
|||||||
@@ -1,9 +1,25 @@
|
|||||||
resource "libvirt_volume" "vm_disk" {
|
# Base volume (template/parent)
|
||||||
count = var.instance_count
|
resource "libvirt_volume" "base_vm_image" {
|
||||||
name = "${var.vm_name}-${count.index}"
|
name = "${var.vm_name}-base"
|
||||||
pool = "${var.vm_name}-pool"
|
pool = "${var.vm_name}-pool"
|
||||||
source = var.image_location
|
source = var.image_location
|
||||||
format = "qcow2"
|
format = "qcow2"
|
||||||
|
|
||||||
depends_on = [libvirt_pool.tf_tmp_storage]
|
depends_on = [
|
||||||
}
|
libvirt_pool.tf_tmp_storage
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clone volume with resizable size
|
||||||
|
resource "libvirt_volume" "vm_disk" {
|
||||||
|
count = var.instance_count
|
||||||
|
name = "${var.vm_name}-${count.index}"
|
||||||
|
pool = "${var.vm_name}-pool"
|
||||||
|
format = "qcow2"
|
||||||
|
size = var.disk_size_bytes
|
||||||
|
base_volume_id = libvirt_volume.base_vm_image.id
|
||||||
|
|
||||||
|
depends_on = [
|
||||||
|
libvirt_volume.base_vm_image
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user