Skip to content

Commit b504f10

Browse files
authored
Expose FIPs in inventory hosts file (#807)
* Expose FIPs in inventory hosts file * adding output for "fip_address" * changing 'fip_address' to 'nodegroup_fips'
1 parent b11696e commit b504f10

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

environments/site/tofu/inventory.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ${cluster_name}_${group_name}:
2626
image_id: ${ node.image_id }
2727
networks: ${jsonencode({for n in node.network: n.name => {"fixed_ip_v4": n.fixed_ip_v4, "fixed_ip_v6": n.fixed_ip_v6}})}
2828
node_fqdn: ${login_groups[group_name]["fqdns"][nodename]}
29+
node_fip: ${login_groups[group_name]["nodegroup_fips"][nodename]}
2930
%{ endfor ~}
3031

3132
${group_name}:
@@ -77,6 +78,7 @@ ${cluster_name}_${group_name}:
7778
instance_id: ${ node.id }
7879
networks: ${jsonencode({for n in node.network: n.name => {"fixed_ip_v4": n.fixed_ip_v4, "fixed_ip_v6": n.fixed_ip_v6}})}
7980
node_fqdn: ${additional_groups[group_name]["fqdns"][nodename]}
81+
node_fip: ${additional_groups[group_name]["nodegroup_fips"][nodename]}
8082
%{ endfor ~}
8183
${group_name}:
8284
children:

environments/site/tofu/node_group/nodes.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ locals {
2525
}
2626
)
2727
}
28+
# Map node names to floating IPs from the list var.fip_addresses by index
29+
nodegroup_fips = {
30+
for idx, n in var.nodes :
31+
n => length(var.fip_addresses) > idx ? var.fip_addresses[idx] : ""
32+
}
2833

2934
baremetal_az = var.availability_zone != null ? var.availability_zone : "nova"
3035
}
@@ -229,3 +234,7 @@ output "image_id" {
229234
output "fqdns" {
230235
value = local.fqdns
231236
}
237+
238+
output "nodegroup_fips" {
239+
value = local.nodegroup_fips
240+
}

0 commit comments

Comments
 (0)