diff --git a/data/data/nutanix/bootstrap/main.tf b/data/data/nutanix/bootstrap/main.tf index aefbb7eb254..4375010524c 100644 --- a/data/data/nutanix/bootstrap/main.tf +++ b/data/data/nutanix/bootstrap/main.tf @@ -24,7 +24,7 @@ resource "nutanix_image" "bootstrap_ignition" { resource "nutanix_virtual_machine" "vm_bootstrap" { name = "${var.cluster_id}-bootstrap" description = local.description - cluster_uuid = var.nutanix_prism_element_uuid + cluster_uuid = var.nutanix_prism_element_uuids[0] num_vcpus_per_socket = 4 num_sockets = 1 memory_size_mib = 16384 @@ -69,6 +69,6 @@ resource "nutanix_virtual_machine" "vm_bootstrap" { } nic_list { - subnet_uuid = var.nutanix_subnet_uuid + subnet_uuid = var.nutanix_subnet_uuids[0] } } diff --git a/data/data/nutanix/cluster/main.tf b/data/data/nutanix/cluster/main.tf index 5036d7e41b4..0aa2f8126c8 100644 --- a/data/data/nutanix/cluster/main.tf +++ b/data/data/nutanix/cluster/main.tf @@ -66,7 +66,7 @@ resource "nutanix_virtual_machine" "vm_master" { count = var.master_count description = local.description name = "${var.cluster_id}-master-${count.index}" - cluster_uuid = var.nutanix_prism_element_uuid + cluster_uuid = var.nutanix_prism_element_uuids[count.index] num_vcpus_per_socket = var.nutanix_control_plane_cores_per_socket num_sockets = var.nutanix_control_plane_num_cpus memory_size_mib = var.nutanix_control_plane_memory_mib @@ -107,6 +107,6 @@ resource "nutanix_virtual_machine" "vm_master" { guest_customization_cloud_init_user_data = base64encode(element(data.ignition_config.master_ignition_config.*.rendered, count.index)) nic_list { - subnet_uuid = var.nutanix_subnet_uuid + subnet_uuid = var.nutanix_subnet_uuids[count.index] } } diff --git a/data/data/nutanix/variables-nutanix.tf b/data/data/nutanix/variables-nutanix.tf index b4d5673dc77..aedef701fa3 100644 --- a/data/data/nutanix/variables-nutanix.tf +++ b/data/data/nutanix/variables-nutanix.tf @@ -22,9 +22,10 @@ variable "nutanix_password" { description = "Prism Central user password" } -variable "nutanix_prism_element_uuid" { - type = string - description = "This is the uuid of the Prism Element cluster." +variable "nutanix_prism_element_uuids" { + type = list(string) + default = [] + description = "This is the uuids of the Prism Element clusters." } variable "nutanix_image_uri" { @@ -37,9 +38,10 @@ variable "nutanix_image" { description = "This is the name to the image that will be imported into Prism Central." } -variable "nutanix_subnet_uuid" { - type = string - description = "This is the uuid of the publicly accessible subnet for cluster ingress and access." +variable "nutanix_subnet_uuids" { + type = list(string) + default = [] + description = "This is the uuids of the publicly accessible subnets for cluster ingress and access." } variable "nutanix_bootstrap_ignition_image" { diff --git a/pkg/tfvars/nutanix/nutanix.go b/pkg/tfvars/nutanix/nutanix.go index 153c74d6984..8fc8cc497bd 100644 --- a/pkg/tfvars/nutanix/nutanix.go +++ b/pkg/tfvars/nutanix/nutanix.go @@ -20,8 +20,8 @@ type config struct { NumCoresPerSocket int64 `json:"nutanix_control_plane_cores_per_socket"` ProjectUUID string `json:"nutanix_control_plane_project_uuid"` Categories map[string]string `json:"nutanix_control_plane_categories"` - PrismElementUUID string `json:"nutanix_prism_element_uuid"` - SubnetUUID string `json:"nutanix_subnet_uuid"` + PrismElementUUIDs []string `json:"nutanix_prism_element_uuids"` + SubnetUUIDs []string `json:"nutanix_subnet_uuids"` Image string `json:"nutanix_image"` ImageURI string `json:"nutanix_image_uri"` BootstrapIgnitionImage string `json:"nutanix_bootstrap_ignition_image"` @@ -49,6 +49,7 @@ func TFVars(sources TFVarsSources) ([]byte, error) { bootstrapIgnitionImageName := nutanixtypes.BootISOImageName(sources.ClusterID) controlPlaneConfig := sources.ControlPlaneConfigs[0] + cpCount := len(sources.ControlPlaneConfigs) cfg := &config{ Port: sources.Port, PrismCentralAddress: sources.PrismCentralAddress, @@ -58,14 +59,19 @@ func TFVars(sources TFVarsSources) ([]byte, error) { DiskSizeMiB: controlPlaneConfig.SystemDiskSize.Value() / (1024 * 1024), NumCPUs: int64(controlPlaneConfig.VCPUSockets), NumCoresPerSocket: int64(controlPlaneConfig.VCPUsPerSocket), - PrismElementUUID: *controlPlaneConfig.Cluster.UUID, - SubnetUUID: *controlPlaneConfig.Subnets[0].UUID, + PrismElementUUIDs: make([]string, cpCount), + SubnetUUIDs: make([]string, cpCount), Image: *controlPlaneConfig.Image.Name, ImageURI: sources.ImageURI, BootstrapIgnitionImage: bootstrapIgnitionImageName, BootstrapIgnitionImageFilePath: bootstrapIgnitionImagePath, } + for i, cpcfg := range sources.ControlPlaneConfigs { + cfg.PrismElementUUIDs[i] = *cpcfg.Cluster.UUID + cfg.SubnetUUIDs[i] = *cpcfg.Subnets[0].UUID + } + if controlPlaneConfig.Project.Type == machinev1.NutanixIdentifierUUID { cfg.ProjectUUID = *controlPlaneConfig.Project.UUID }