From 3c057f709245b7cbb0adcdcce26d52dce67b3adf Mon Sep 17 00:00:00 2001 From: William <3422794+FriedCircuits@users.noreply.github.com> Date: Thu, 28 Apr 2022 04:54:39 +0000 Subject: [PATCH 1/2] Add var for extra disks --- modules/proxmox/vm-clone/main.tf | 33 +++++++++++++++++---------- modules/proxmox/vm-clone/variables.tf | 16 ++++++++++--- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/modules/proxmox/vm-clone/main.tf b/modules/proxmox/vm-clone/main.tf index 1383404..065bef0 100644 --- a/modules/proxmox/vm-clone/main.tf +++ b/modules/proxmox/vm-clone/main.tf @@ -2,7 +2,7 @@ terraform { required_version = ">= 1.0" required_providers { proxmox = { - source = "Telmate/proxmox" + source = "Telmate/proxmox" version = "~>2.9" } } @@ -14,10 +14,10 @@ resource "null_resource" "cloud_init" { } connection { - type = "ssh" - user = var.pve_connection.ssh_user + type = "ssh" + user = var.pve_connection.ssh_user private_key = var.pve_connection.private_key - host = var.pve_connection.host + host = var.pve_connection.host } provisioner "file" { @@ -36,26 +36,35 @@ resource "proxmox_vm_qemu" "vm" { onboot = var.onboot oncreate = var.oncreate - clone = var.clone + clone = var.clone full_clone = var.full_clone disk { - slot = 0 + slot = 0 storage = var.specs.disk_storage - type = var.specs.disk_type - size = var.specs.disk_size + type = var.specs.disk_type + size = var.specs.disk_size } - cores = var.specs.cores + dynamic "disk" { + for_each = var.extra_disks != null ? var.extra_disks : [] + content { + storage = disk.value["storage"] + type = disk.value["type"] + size = disk.value["size"] + } + } + + cores = var.specs.cores sockets = var.specs.sockets - memory = var.specs.memory + memory = var.specs.memory network { - model = "virtio" + model = "virtio" bridge = "vmbr0" } - os_type = "cloud-init" + os_type = "cloud-init" ipconfig0 = "ip=dhcp" cicustom = "user=local:snippets/cloud_init_${var.vm.name}.yml" diff --git a/modules/proxmox/vm-clone/variables.tf b/modules/proxmox/vm-clone/variables.tf index 5a63c47..037cc94 100644 --- a/modules/proxmox/vm-clone/variables.tf +++ b/modules/proxmox/vm-clone/variables.tf @@ -1,6 +1,6 @@ variable "pve_connection" { description = "Connection info for PVE host." - type = object({ + type = object({ node = string host = string ssh_user = string @@ -15,7 +15,7 @@ variable "clone" { variable "vm" { description = "Name of VM to deploy." - type = object({ + type = object({ name = string description = string }) @@ -41,7 +41,7 @@ variable "agent_enabled" { variable "specs" { description = "CPU, Mem settings per VM." - type = object({ + type = object({ cores = number sockets = number memory = number @@ -59,6 +59,16 @@ variable "specs" { } } +variable "extra_disks" { + description = "Add extra disk to create and attach to the VM." + type = list(object({ + storage = string + type = string + size = string + })) + default = [] +} + variable "tags" { description = "Comma delimited strings to pass as tags to the vm. Note not visable in the UI." type = string From 2c845bdd5d205186f7e4f93c0741d4e16e2d42e6 Mon Sep 17 00:00:00 2001 From: William <3422794+FriedCircuits@users.noreply.github.com> Date: Thu, 28 Apr 2022 04:55:35 +0000 Subject: [PATCH 2/2] Bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 03ac640..3802e7d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.0.13 +v0.0.14