From eae0dbce650abb7afae149634790d9d269e9c5fe Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Wed, 5 Jul 2023 09:49:30 +0200 Subject: [PATCH] fix(vmware): adding name param to network definitions --- modules/vmware/main.tf | 21 +++++++++------------ modules/vmware/version.tf | 4 ++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/modules/vmware/main.tf b/modules/vmware/main.tf index b5aaca1..339d854 100644 --- a/modules/vmware/main.tf +++ b/modules/vmware/main.tf @@ -5,17 +5,15 @@ variable "vms" { cpu = number ram = number guest_id = string - disks = list(object({ - name = string + disks = map(object({ size = string })) network_interfaces = map(object( { + name = string mac = string } )) - resource_pool_id = string - datastore_id = string folder = string } )) @@ -23,14 +21,13 @@ variable "vms" { } variable "cluster" { - type = map(object( - { + type = object({ datacenter_name = string datastore_name = string resource_pool_name = string folder = string } - )) + ) description = "vSphere cluster definition" } @@ -51,16 +48,16 @@ data "vsphere_resource_pool" "pool" { data "vsphere_network" "network" { count = length(var.vms.network_interfaces) - name = var.networks[count.index].key + name = var.networks[count.index].name datacenter_id = data.vsphere_datacenter.datacenter.id } -resource "vphere_virtual_virtual_machine" "vm" { +resource "vsphere_virtual_machine" "vm" { for_each = var.vms iterator = "machine" name = "${machine.key}.${machine.value.domain}" - resource_pool_id = "${machine.key.resource_pool_id}" - datastore_id = machine.key.datastore_id + resource_pool_id = data.vsphere_resource_pool.id + datastore_id = data.vsphere_datastore.id folder = machine.folder num_cpus = machine.cpu memory = machine.ram @@ -76,7 +73,7 @@ resource "vphere_virtual_virtual_machine" "vm" { dynamic "disk" { for_each = each.key.disks content { - label = each.key.name + label = each.key size = each.key.size } } diff --git a/modules/vmware/version.tf b/modules/vmware/version.tf index 838dedb..da87832 100644 --- a/modules/vmware/version.tf +++ b/modules/vmware/version.tf @@ -1,7 +1,7 @@ terraform { required_providers { - opennebula = { - source = "hashicorp/vsphere" + vsphere = { + source = "hashicorp/vsphere" version = "~> 2.4.0" } }