Skip to content

Commit 25af907

Browse files
committed
add support for additional_nodegroups
1 parent e1b171d commit 25af907

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resource "local_file" "hosts" {
66
"control": openstack_compute_instance_v2.control
77
"login_groups": module.login
88
"compute_groups": module.compute
9+
"additional_groups": module.additional
910
"state_dir": var.state_dir
1011
"cluster_home_volume": var.home_volume_provisioning != "none"
1112
},

environments/skeleton/{{cookiecutter.environment}}/tofu/inventory.tpl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ control:
1414
vars:
1515
appliances_state_dir: ${state_dir} # NB needs to be set on group not host otherwise it is ignored in packer build!
1616

17+
# --- login nodes ---
1718
%{ for group_name in keys(login_groups) ~}
1819
${cluster_name}_${group_name}:
1920
hosts:
@@ -32,6 +33,7 @@ login:
3233
${cluster_name}_${group_name}:
3334
%{ endfor ~}
3435

36+
# --- compute nodes ---
3537
%{ for group_name in keys(compute_groups) ~}
3638
${cluster_name}_${group_name}:
3739
hosts:
@@ -44,10 +46,36 @@ ${cluster_name}_${group_name}:
4446
vars:
4547
# NB: this is the target image, not necessarily what is provisioned
4648
image_id: ${compute_groups[group_name]["image_id"]}
49+
50+
${group_name}:
51+
children:
52+
${cluster_name}_${group_name}:
53+
4754
%{ endfor ~}
4855

4956
compute:
5057
children:
5158
%{ for group_name in keys(compute_groups) ~}
5259
${cluster_name}_${group_name}:
5360
%{ endfor ~}
61+
62+
# --- additional nodes ---
63+
%{ for group_name in keys(additional_groups) ~}
64+
${cluster_name}_${group_name}:
65+
hosts:
66+
%{ for node in additional_groups[group_name]["compute_instances"] ~}
67+
${ node.name }:
68+
ansible_host: ${node.access_ip_v4}
69+
instance_id: ${ node.id }
70+
networks: ${jsonencode({for n in node.network: n.name => {"fixed_ip_v4": n.fixed_ip_v4, "fixed_ip_v6": n.fixed_ip_v6}})}
71+
%{ endfor ~}
72+
${group_name}:
73+
children:
74+
${cluster_name}_${group_name}:
75+
76+
%{ endfor ~}
77+
additional:
78+
children:
79+
%{ for group_name in keys(additional_groups) ~}
80+
${cluster_name}_${group_name}:
81+
%{ endfor ~}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module "login" {
2222
gateway_ip = lookup(each.value, "gateway_ip", var.gateway_ip)
2323
nodename_template = lookup(each.value, "nodename_template", var.cluster_nodename_template)
2424

25-
# optionally set for group
25+
# optionally set for group:
2626
networks = concat(var.cluster_networks, lookup(each.value, "extra_networks", []))
2727
# here null means "use module var default"
2828
extra_volumes = lookup(each.value, "extra_volumes", null)

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,33 @@ variable "compute" {
125125
availability_zone: Name of availability zone - ignored unless match_ironic_node is true (default: "nova")
126126
gateway_ip: Address to add default route via
127127
nodename_template: Overrides variable cluster_nodename_template
128+
129+
Nodes are added to the following inventory groups:
130+
- $group_name
131+
- $cluster_name + '_' + $group_name - this is used for the stackhpc.openhpc role
132+
- 'compute'
128133
EOF
129134

130135
type = any # can't do any better; TF type constraints can't cope with heterogeneous inner mappings
131136
}
132137

138+
variable "additional_nodegroups" {
139+
default = {}
140+
description = <<-EOF
141+
Mapping defining homogenous groups of nodes for arbitrary purposes.
142+
These nodes are not in the compute or login inventory groups so they
143+
will not run slurmd.
144+
145+
Keys are names of groups.
146+
Values are a mapping as for the "login" variable.
147+
148+
Nodes are added to the following inventory groups:
149+
- $group_name
150+
- $cluster_name + '_' + $group_name
151+
- 'additional'
152+
EOF
153+
}
154+
133155
variable "environment_root" {
134156
type = string
135157
description = "Path to environment root, automatically set by activate script"

0 commit comments

Comments
 (0)