Skip to content

Commit

Permalink
Merge pull request #7016 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…6981-to-release-4.13

[release-4.13] OCPBUGS-10493: Nutanix Hostname of the VM is not set when using DHCP network config
  • Loading branch information
openshift-merge-robot committed May 26, 2023
2 parents 6aafbeb + 77eca05 commit b332f7a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
42 changes: 33 additions & 9 deletions data/data/nutanix/cluster/main.tf
Expand Up @@ -38,14 +38,38 @@ resource "nutanix_image" "rhcos" {
}
}

data "ignition_file" "hostname" {
count = var.master_count
mode = "420" // 0644
path = "/etc/hostname"

content {
content = <<EOF
${var.cluster_id}-master-${count.index}
EOF
}
}

data "ignition_config" "master_ignition_config" {
count = var.master_count

merge {
source = "data:text/plain;charset=utf-8;base64,${base64encode(var.ignition_master)}"
}

files = [
element(data.ignition_file.hostname.*.rendered, count.index)
]
}

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
count = var.master_count
description = local.description
name = "${var.cluster_id}-master-${count.index}"
cluster_uuid = var.nutanix_prism_element_uuid
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
num_sockets = var.nutanix_control_plane_num_cpus
memory_size_mib = var.nutanix_control_plane_memory_mib
boot_device_order_list = [
"DISK",
"CDROM",
Expand All @@ -67,21 +91,21 @@ resource "nutanix_virtual_machine" "vm_master" {
}

categories {
name = nutanix_category_key.ocp_category_key.name
name = nutanix_category_key.ocp_category_key.name
value = nutanix_category_value.ocp_category_value_owned.value
}

dynamic "categories" {
for_each = (var.nutanix_control_plane_categories == null) ? {} : var.nutanix_control_plane_categories
content {
name = categories.key
name = categories.key
value = categories.value
}
}

project_reference = (length(var.nutanix_control_plane_project_uuid) != 0) ? { kind = "project", uuid = var.nutanix_control_plane_project_uuid } : null

guest_customization_cloud_init_user_data = base64encode(var.ignition_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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/terraform/stages/nutanix/stages.go
Expand Up @@ -8,6 +8,6 @@ import (

// PlatformStages are the stages to run to provision the infrastructure in Nutanix.
var PlatformStages = []terraform.Stage{
stages.NewStage("nutanix", "cluster", []providers.Provider{providers.Nutanix}),
stages.NewStage("nutanix", "cluster", []providers.Provider{providers.Nutanix, providers.Ignition}),
stages.NewStage("nutanix", "bootstrap", []providers.Provider{providers.Nutanix}, stages.WithNormalBootstrapDestroy()),
}

0 comments on commit b332f7a

Please sign in to comment.