Skip to content

Commit

Permalink
Handle new vmrpid variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Léo GATELLIER committed Oct 26, 2022
1 parent 3920a4b commit 881a04c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 881a04c

Please sign in to comment.