Skip to content

Commit 8f60a4d

Browse files
committed
Allow use of Ironic node name as instance name (site)
1 parent b8d7b4c commit 8f60a4d

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

environments/production/tofu/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ module "cluster" {
4747
}
4848
]
4949
match_ironic_node = true
50+
use_ironic_node_name = true
5051
vnic_types = {
5152
netapp = "baremetal"
5253
infiniband = "baremetal"
@@ -72,6 +73,7 @@ module "cluster" {
7273
}
7374
]
7475
match_ironic_node = true
76+
use_ironic_node_name = true
7577
vnic_types = {
7678
netapp = "baremetal"
7779
infiniband = "baremetal"

environments/site/tofu/node_group/nodes.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ resource "openstack_compute_instance_v2" "compute_fixed_image" {
6161

6262
for_each = var.ignore_image_changes ? toset(var.nodes) : []
6363

64-
name = "${var.cluster_name}-${each.key}"
64+
name = var.use_ironic_node_name ? "${each.key}" : "${var.cluster_name}-${each.key}"
6565
image_id = var.image_id
6666
flavor_name = var.flavor
6767
key_pair = var.key_pair
@@ -98,7 +98,7 @@ resource "openstack_compute_instance_v2" "compute_fixed_image" {
9898

9999
user_data = <<-EOF
100100
#cloud-config
101-
fqdn: ${var.cluster_name}-${each.key}.${var.cluster_name}.${var.cluster_domain_suffix}
101+
fqdn: ${var.use_ironic_node_name ? "${each.key}" : "${var.cluster_name}-${each.key}"}.${var.cluster_name}.${var.cluster_domain_suffix}
102102
EOF
103103

104104
availability_zone = var.match_ironic_node ? "${var.availability_zone}::${var.baremetal_nodes[each.key]}" : null
@@ -115,7 +115,7 @@ resource "openstack_compute_instance_v2" "compute" {
115115

116116
for_each = var.ignore_image_changes ? [] : toset(var.nodes)
117117

118-
name = "${var.cluster_name}-${each.key}"
118+
name = var.use_ironic_node_name ? "${each.key}" : "${var.cluster_name}-${each.key}"
119119
image_id = var.image_id
120120
flavor_name = var.flavor
121121
key_pair = var.key_pair
@@ -152,7 +152,7 @@ resource "openstack_compute_instance_v2" "compute" {
152152

153153
user_data = <<-EOF
154154
#cloud-config
155-
fqdn: ${var.cluster_name}-${each.key}.${var.cluster_name}.${var.cluster_domain_suffix}
155+
fqdn: ${var.use_ironic_node_name ? "${each.key}" : "${var.cluster_name}-${each.key}"}.${var.cluster_name}.${var.cluster_domain_suffix}
156156
EOF
157157

158158
availability_zone = var.match_ironic_node ? "${var.availability_zone}::${var.baremetal_nodes[each.key]}" : null

environments/site/tofu/node_group/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ variable "match_ironic_node" {
112112
default = false
113113
}
114114

115+
variable "use_ironic_node_name" {
116+
type = bool
117+
description = "Whether to name instances and their FQDN the same as the matching Ironic node (no cluster name)"
118+
default = false
119+
}
120+
115121
variable "availability_zone" {
116122
type = string
117123
description = "Name of availability zone - ignored unless match_ironic_node is true"

environments/skeleton/{{cookiecutter.environment}}/tofu/compute.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module "compute" {
2727
ignore_image_changes = lookup(each.value, "ignore_image_changes", false)
2828
match_ironic_node = lookup(each.value, "match_ironic_node", false)
2929
availability_zone = lookup(each.value, "availability_zone", "nova")
30+
use_ironic_node_name = lookup(each.value, "use_ironic_node_name", false)
3031

3132
# computed
3233
# not using openstack_compute_instance_v2.control.access_ip_v4 to avoid

0 commit comments

Comments
 (0)