Skip to content

Commit e44ef17

Browse files
Merge pull request #7806 from nutanix-cloud-native/nutanix-failuredomains
SPLAT-1272: Modify the terraform variables to support Nutanix Failure Domains
2 parents 46fd662 + e89afe0 commit e44ef17

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

data/data/nutanix/bootstrap/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ resource "nutanix_image" "bootstrap_ignition" {
2424
resource "nutanix_virtual_machine" "vm_bootstrap" {
2525
name = "${var.cluster_id}-bootstrap"
2626
description = local.description
27-
cluster_uuid = var.nutanix_prism_element_uuid
27+
cluster_uuid = var.nutanix_prism_element_uuids[0]
2828
num_vcpus_per_socket = 4
2929
num_sockets = 1
3030
memory_size_mib = 16384
@@ -69,6 +69,6 @@ resource "nutanix_virtual_machine" "vm_bootstrap" {
6969
}
7070

7171
nic_list {
72-
subnet_uuid = var.nutanix_subnet_uuid
72+
subnet_uuid = var.nutanix_subnet_uuids[0]
7373
}
7474
}

data/data/nutanix/cluster/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ resource "nutanix_virtual_machine" "vm_master" {
6666
count = var.master_count
6767
description = local.description
6868
name = "${var.cluster_id}-master-${count.index}"
69-
cluster_uuid = var.nutanix_prism_element_uuid
69+
cluster_uuid = var.nutanix_prism_element_uuids[count.index]
7070
num_vcpus_per_socket = var.nutanix_control_plane_cores_per_socket
7171
num_sockets = var.nutanix_control_plane_num_cpus
7272
memory_size_mib = var.nutanix_control_plane_memory_mib
@@ -107,6 +107,6 @@ resource "nutanix_virtual_machine" "vm_master" {
107107

108108
guest_customization_cloud_init_user_data = base64encode(element(data.ignition_config.master_ignition_config.*.rendered, count.index))
109109
nic_list {
110-
subnet_uuid = var.nutanix_subnet_uuid
110+
subnet_uuid = var.nutanix_subnet_uuids[count.index]
111111
}
112112
}

data/data/nutanix/variables-nutanix.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ variable "nutanix_password" {
2222
description = "Prism Central user password"
2323
}
2424

25-
variable "nutanix_prism_element_uuid" {
26-
type = string
27-
description = "This is the uuid of the Prism Element cluster."
25+
variable "nutanix_prism_element_uuids" {
26+
type = list(string)
27+
default = []
28+
description = "This is the uuids of the Prism Element clusters."
2829
}
2930

3031
variable "nutanix_image_uri" {
@@ -37,9 +38,10 @@ variable "nutanix_image" {
3738
description = "This is the name to the image that will be imported into Prism Central."
3839
}
3940

40-
variable "nutanix_subnet_uuid" {
41-
type = string
42-
description = "This is the uuid of the publicly accessible subnet for cluster ingress and access."
41+
variable "nutanix_subnet_uuids" {
42+
type = list(string)
43+
default = []
44+
description = "This is the uuids of the publicly accessible subnets for cluster ingress and access."
4345
}
4446

4547
variable "nutanix_bootstrap_ignition_image" {

pkg/tfvars/nutanix/nutanix.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type config struct {
2020
NumCoresPerSocket int64 `json:"nutanix_control_plane_cores_per_socket"`
2121
ProjectUUID string `json:"nutanix_control_plane_project_uuid"`
2222
Categories map[string]string `json:"nutanix_control_plane_categories"`
23-
PrismElementUUID string `json:"nutanix_prism_element_uuid"`
24-
SubnetUUID string `json:"nutanix_subnet_uuid"`
23+
PrismElementUUIDs []string `json:"nutanix_prism_element_uuids"`
24+
SubnetUUIDs []string `json:"nutanix_subnet_uuids"`
2525
Image string `json:"nutanix_image"`
2626
ImageURI string `json:"nutanix_image_uri"`
2727
BootstrapIgnitionImage string `json:"nutanix_bootstrap_ignition_image"`
@@ -49,6 +49,7 @@ func TFVars(sources TFVarsSources) ([]byte, error) {
4949

5050
bootstrapIgnitionImageName := nutanixtypes.BootISOImageName(sources.ClusterID)
5151
controlPlaneConfig := sources.ControlPlaneConfigs[0]
52+
cpCount := len(sources.ControlPlaneConfigs)
5253
cfg := &config{
5354
Port: sources.Port,
5455
PrismCentralAddress: sources.PrismCentralAddress,
@@ -58,14 +59,19 @@ func TFVars(sources TFVarsSources) ([]byte, error) {
5859
DiskSizeMiB: controlPlaneConfig.SystemDiskSize.Value() / (1024 * 1024),
5960
NumCPUs: int64(controlPlaneConfig.VCPUSockets),
6061
NumCoresPerSocket: int64(controlPlaneConfig.VCPUsPerSocket),
61-
PrismElementUUID: *controlPlaneConfig.Cluster.UUID,
62-
SubnetUUID: *controlPlaneConfig.Subnets[0].UUID,
62+
PrismElementUUIDs: make([]string, cpCount),
63+
SubnetUUIDs: make([]string, cpCount),
6364
Image: *controlPlaneConfig.Image.Name,
6465
ImageURI: sources.ImageURI,
6566
BootstrapIgnitionImage: bootstrapIgnitionImageName,
6667
BootstrapIgnitionImageFilePath: bootstrapIgnitionImagePath,
6768
}
6869

70+
for i, cpcfg := range sources.ControlPlaneConfigs {
71+
cfg.PrismElementUUIDs[i] = *cpcfg.Cluster.UUID
72+
cfg.SubnetUUIDs[i] = *cpcfg.Subnets[0].UUID
73+
}
74+
6975
if controlPlaneConfig.Project.Type == machinev1.NutanixIdentifierUUID {
7076
cfg.ProjectUUID = *controlPlaneConfig.Project.UUID
7177
}

0 commit comments

Comments
 (0)