Skip to content

Commit 4a48c2f

Browse files
committed
Merge branch 'main' into feat/isolated-env-2
2 parents 963f0ff + ff7aef8 commit 4a48c2f

File tree

10 files changed

+154
-17
lines changed

10 files changed

+154
-17
lines changed

ansible/roles/nhc/templates/nhc.conf.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* || HOSTNAME="$HOSTNAME_S"
55

66
## Filesystem checks
7-
{% for mount in ansible_mounts %}
7+
{% for mount in ansible_mounts | rejectattr('mount', 'eq', '/efi') %}
8+
{# /efi is mounted both directly and via systemd1 autofs, which NHC can't cope with #}
9+
{# use `awk '{print $5 " " $10 " " $4 " " $9}' /proc/self/mountinfo | sort -k1` to check that is the only case #}
810
{% set mount_mode = 'rw' if 'rw' in mount.options.split(',') else 'ro' %}
911
{{ ansible_fqdn }} || check_fs_mount_{{ mount_mode }} -t "{{ mount.fstype }}" -s "{{ mount.device }}" -f "{{ mount.mount }}"
1012
{% endfor %}

ansible/site.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
- import_playbook: slurm.yml
2828
- import_playbook: portal.yml
2929
- import_playbook: monitoring.yml
30-
- import_playbook: final.yml
3130

3231
- name: Run post.yml hook
3332
vars:
@@ -37,4 +36,6 @@
3736
import_playbook: "{{ hook_path if hook_path | exists else 'noop.yml' }}"
3837
when: hook_path | exists
3938

39+
- import_playbook: final.yml
40+
4041
...
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
module "additional" {
2+
source = "./node_group"
3+
4+
for_each = var.additional_nodegroups
5+
6+
# must be set for group:
7+
nodes = each.value.nodes
8+
flavor = each.value.flavor
9+
10+
# always taken from top-level value:
11+
cluster_name = var.cluster_name
12+
cluster_domain_suffix = var.cluster_domain_suffix
13+
key_pair = var.key_pair
14+
environment_root = var.environment_root
15+
16+
# can be set for group, defaults to top-level value:
17+
image_id = lookup(each.value, "image_id", var.cluster_image_id)
18+
vnic_types = lookup(each.value, "vnic_types", var.vnic_types)
19+
volume_backed_instances = lookup(each.value, "volume_backed_instances", var.volume_backed_instances)
20+
root_volume_size = lookup(each.value, "root_volume_size", var.root_volume_size)
21+
root_volume_type = lookup(each.value, "root_volume_type", var.root_volume_type)
22+
gateway_ip = lookup(each.value, "gateway_ip", var.gateway_ip)
23+
nodename_template = lookup(each.value, "nodename_template", var.cluster_nodename_template)
24+
25+
# optionally set for group:
26+
networks = concat(var.cluster_networks, lookup(each.value, "extra_networks", []))
27+
# here null means "use module var default"
28+
extra_volumes = lookup(each.value, "extra_volumes", null)
29+
fip_addresses = lookup(each.value, "fip_addresses", null)
30+
fip_network = lookup(each.value, "fip_network", null)
31+
match_ironic_node = lookup(each.value, "match_ironic_node", null)
32+
availability_zone = lookup(each.value, "availability_zone", null)
33+
ip_addresses = lookup(each.value, "ip_addresses", null)
34+
security_group_ids = lookup(each.value, "security_group_ids", [for o in data.openstack_networking_secgroup_v2.nonlogin: o.id])
35+
36+
# can't be set for additional nodes
37+
compute_init_enable = []
38+
ignore_image_changes = false
39+
40+
# computed
41+
# not using openstack_compute_instance_v2.control.access_ip_v4 to avoid
42+
# updates to node metadata on deletion/recreation of the control node:
43+
control_address = openstack_networking_port_v2.control[var.cluster_networks[0].network].all_fixed_ips[0]
44+
baremetal_nodes = data.external.baremetal_nodes.result
45+
46+
# input dict validation:
47+
group_name = each.key
48+
group_keys = keys(each.value)
49+
allowed_keys = [
50+
"nodes",
51+
"flavor",
52+
"image_id",
53+
"extra_networks",
54+
"vnic_types",
55+
"volume_backed_instances",
56+
"root_volume_size",
57+
"root_volume_type",
58+
"extra_volumes",
59+
"fip_addresses",
60+
"fip_network",
61+
"match_ironic_node",
62+
"availability_zone",
63+
"ip_addresses",
64+
"gateway_ip",
65+
"nodename_template",
66+
"security_group_ids",
67+
]
68+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ locals {
44
[for v in data.openstack_blockstorage_volume_v3.state: v],
55
[for v in data.openstack_blockstorage_volume_v3.home: v]
66
)
7-
nodename = templatestring(
7+
control_fqdn = templatestring(
88
var.cluster_nodename_template,
99
{
1010
node = "control",
@@ -38,7 +38,7 @@ resource "openstack_networking_port_v2" "control" {
3838

3939
resource "openstack_compute_instance_v2" "control" {
4040

41-
name = split(".", local.nodename)[0]
41+
name = split(".", local.control_fqdn)[0]
4242
image_id = var.cluster_image_id
4343
flavor_name = var.control_node_flavor
4444
key_pair = var.key_pair
@@ -80,7 +80,7 @@ resource "openstack_compute_instance_v2" "control" {
8080

8181
user_data = <<-EOF
8282
#cloud-config
83-
fqdn: ${local.nodename}
83+
fqdn: ${local.control_fqdn}
8484
8585
bootcmd:
8686
%{for volume in local.control_volumes}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ resource "local_file" "hosts" {
22
content = templatefile("${path.module}/inventory.tpl",
33
{
44
"cluster_name": var.cluster_name,
5-
"cluster_domain_suffix": var.cluster_domain_suffix,
5+
"cluster_domain_suffix": var.cluster_domain_suffix
66
"control": openstack_compute_instance_v2.control
7+
"control_fqdn": local.control_fqdn
78
"login_groups": module.login
89
"compute_groups": module.compute
10+
"additional_groups": module.additional
911
"state_dir": var.state_dir
1012
"cluster_home_volume": var.home_volume_provisioning != "none"
1113
},

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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ control:
1111
ansible_host: ${control.access_ip_v4}
1212
instance_id: ${control.id}
1313
networks: ${jsonencode({for n in control.network: n.name => {"fixed_ip_v4": n.fixed_ip_v4, "fixed_ip_v6": n.fixed_ip_v6}})}
14+
node_fqdn: ${control_fqdn}
1415
vars:
1516
appliances_state_dir: ${state_dir} # NB needs to be set on group not host otherwise it is ignored in packer build!
1617

18+
# --- login nodes ---
1719
%{ for group_name in keys(login_groups) ~}
1820
${cluster_name}_${group_name}:
1921
hosts:
20-
%{ for node in login_groups[group_name]["compute_instances"] ~}
22+
%{ for nodename, node in login_groups[group_name]["compute_instances"] ~}
2123
${ node.name }:
2224
ansible_host: ${node.access_ip_v4}
2325
instance_id: ${ node.id }
2426
image_id: ${ node.image_id }
2527
networks: ${jsonencode({for n in node.network: n.name => {"fixed_ip_v4": n.fixed_ip_v4, "fixed_ip_v6": n.fixed_ip_v6}})}
28+
node_fqdn: ${login_groups[group_name]["fqdns"][nodename]}
2629
%{ endfor ~}
2730
%{ endfor ~}
2831

@@ -32,22 +35,51 @@ login:
3235
${cluster_name}_${group_name}:
3336
%{ endfor ~}
3437

38+
# --- compute nodes ---
3539
%{ for group_name in keys(compute_groups) ~}
3640
${cluster_name}_${group_name}:
3741
hosts:
38-
%{ for node in compute_groups[group_name]["compute_instances"] ~}
42+
%{ for nodename, node in compute_groups[group_name]["compute_instances"] ~}
3943
${ node.name }:
4044
ansible_host: ${node.access_ip_v4}
4145
instance_id: ${ node.id }
4246
networks: ${jsonencode({for n in node.network: n.name => {"fixed_ip_v4": n.fixed_ip_v4, "fixed_ip_v6": n.fixed_ip_v6}})}
47+
node_fqdn: ${compute_groups[group_name]["fqdns"][nodename]}
4348
%{ endfor ~}
4449
vars:
4550
# NB: this is the target image, not necessarily what is provisioned
4651
image_id: ${compute_groups[group_name]["image_id"]}
52+
53+
${group_name}:
54+
children:
55+
${cluster_name}_${group_name}:
56+
4757
%{ endfor ~}
4858

4959
compute:
5060
children:
5161
%{ for group_name in keys(compute_groups) ~}
5262
${cluster_name}_${group_name}:
5363
%{ endfor ~}
64+
65+
# --- additional nodes ---
66+
%{ for group_name in keys(additional_groups) ~}
67+
${cluster_name}_${group_name}:
68+
hosts:
69+
%{ for nodename, node in additional_groups[group_name]["compute_instances"] ~}
70+
${ node.name }:
71+
ansible_host: ${node.access_ip_v4}
72+
instance_id: ${ node.id }
73+
networks: ${jsonencode({for n in node.network: n.name => {"fixed_ip_v4": n.fixed_ip_v4, "fixed_ip_v6": n.fixed_ip_v6}})}
74+
node_fqdn: ${additional_groups[group_name]["fqdns"][nodename]}
75+
%{ endfor ~}
76+
${group_name}:
77+
children:
78+
${cluster_name}_${group_name}:
79+
80+
%{ endfor ~}
81+
additional:
82+
children:
83+
%{ for group_name in keys(additional_groups) ~}
84+
${cluster_name}_${group_name}:
85+
%{ 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/node_group/nodes.tf

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ locals {
1313
# Workaround for lifecycle meta-argument only taking static values
1414
compute_instances = var.ignore_image_changes ? openstack_compute_instance_v2.compute_fixed_image : openstack_compute_instance_v2.compute
1515

16-
# Define nodenames here to avoid repetition
17-
nodenames = {
16+
# Define fully qualified nodenames here to avoid repetition
17+
fqdns = {
1818
for n in var.nodes: n => templatestring(
1919
var.nodename_template,
2020
{
@@ -74,7 +74,7 @@ resource "openstack_compute_instance_v2" "compute_fixed_image" {
7474

7575
for_each = var.ignore_image_changes ? toset(var.nodes) : []
7676

77-
name = split(".", local.nodenames[each.key])[0]
77+
name = split(".", local.fqdns[each.key])[0]
7878
image_id = var.image_id
7979
flavor_name = var.flavor
8080
key_pair = var.key_pair
@@ -112,7 +112,7 @@ resource "openstack_compute_instance_v2" "compute_fixed_image" {
112112

113113
user_data = <<-EOF
114114
#cloud-config
115-
fqdn: ${local.nodenames[each.key]}
115+
fqdn: ${local.fqdns[each.key]}
116116
EOF
117117

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

130130
for_each = var.ignore_image_changes ? [] : toset(var.nodes)
131131

132-
name = split(".", local.nodenames[each.key])[0]
132+
name = split(".", local.fqdns[each.key])[0]
133133
image_id = var.image_id
134134
flavor_name = var.flavor
135135
key_pair = var.key_pair
@@ -167,7 +167,7 @@ resource "openstack_compute_instance_v2" "compute" {
167167

168168
user_data = <<-EOF
169169
#cloud-config
170-
fqdn: ${local.nodenames[each.key]}
170+
fqdn: ${local.fqdns[each.key]}
171171
EOF
172172

173173
availability_zone = var.match_ironic_node ? "${var.availability_zone}::${var.baremetal_nodes[each.key]}" : null
@@ -183,9 +183,13 @@ resource "openstack_networking_floatingip_associate_v2" "fip" {
183183
}
184184

185185
output "compute_instances" {
186-
value = local.compute_instances
186+
value = local.compute_instances
187187
}
188188

189189
output "image_id" {
190190
value = var.image_id
191191
}
192+
193+
output "fqdns" {
194+
value = local.fqdns
195+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ variable "extra_volumes" {
7272
}
7373

7474
variable "security_group_ids" {
75-
type = list
75+
type = list(string)
76+
nullable = false
7677
}
7778

7879
variable "control_address" {

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,38 @@ 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, with the addition of
147+
the optional entry:
148+
149+
security_group_ids: List of strings giving IDs of security groups
150+
to apply. If not specified the groups from the
151+
variable nonlogin_security_groups are applied.
152+
153+
Nodes are added to the following inventory groups:
154+
- $group_name
155+
- $cluster_name + '_' + $group_name
156+
- 'additional'
157+
EOF
158+
}
159+
133160
variable "environment_root" {
134161
type = string
135162
description = "Path to environment root, automatically set by activate script"

0 commit comments

Comments
 (0)