Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/data/nutanix/bootstrap/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
}
}
4 changes: 2 additions & 2 deletions data/data/nutanix/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
}
}
14 changes: 8 additions & 6 deletions data/data/nutanix/variables-nutanix.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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" {
Expand Down
14 changes: 10 additions & 4 deletions pkg/tfvars/nutanix/nutanix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
Expand Down