From 881a04c2b51bff1ac84a67b09793d059772d1e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20GATELLIER?= Date: Wed, 12 Oct 2022 16:45:40 +0200 Subject: [PATCH] Handle new vmrpid variable --- main.tf | 3 ++- output.tf | 2 +- variables.tf | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index e813f78..0fc1bcc 100644 --- a/main.tf +++ b/main.tf @@ -21,6 +21,7 @@ data "vsphere_datastore" "disk_datastore" { } data "vsphere_resource_pool" "pool" { + count = var.vmrp != "" ? 1 : 0 name = var.vmrp datacenter_id = data.vsphere_datacenter.dc.id } @@ -81,7 +82,7 @@ resource "vsphere_virtual_machine" "vm" { depends_on = [var.vm_depends_on] name = var.staticvmname != null ? var.staticvmname : format("${var.vmname}${var.vmnameformat}", count.index + 1) - resource_pool_id = data.vsphere_resource_pool.pool.id + resource_pool_id = var.vmrp != "" ? data.vsphere_resource_pool.pool[0].id : var.vmrpid folder = var.vmfolder tags = var.tag_ids != null ? var.tag_ids : data.vsphere_tag.tag[*].id custom_attributes = var.custom_attributes diff --git a/output.tf b/output.tf index aabddda..722179b 100644 --- a/output.tf +++ b/output.tf @@ -5,7 +5,7 @@ output "DC_ID" { output "ResPool_ID" { description = "Resource Pool id" - value = data.vsphere_resource_pool.pool.id + value = var.vmrp != "" ? data.vsphere_resource_pool.pool[0].id : var.vmrpid } output "VM" { diff --git a/variables.tf b/variables.tf index e7f0033..22c4c93 100644 --- a/variables.tf +++ b/variables.tf @@ -175,8 +175,14 @@ variable "dc" { description = "Name of the datacenter you want to deploy the VM to." } +variable "vmrpid" { + description = "ID of cluster resource pool that VM will be deployed to. you use following to choose default pool in the cluster (esxi1) or (Cluster)/Resources." + default = "" +} + variable "vmrp" { description = "Cluster resource pool that VM will be deployed to. you use following to choose default pool in the cluster (esxi1) or (Cluster)/Resources." + default = "" } variable "vmfolder" {