Skip to content

Commit 4433026

Browse files
authored
Merge pull request #391 from stackhpc/add-storage-network
add storage VLAN interface on all slurm nodes
2 parents a0109b4 + ba8b7f3 commit 4433026

File tree

1 file changed

+94
-17
lines changed

1 file changed

+94
-17
lines changed

ansible/roles/cluster_infra/templates/resources.tf.j2

Lines changed: 94 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ data "openstack_networking_network_v2" "cluster_external_network" {
116116
name = "{{ cluster_external_network }}"
117117
}
118118

119+
# Storage network
120+
{% if cluster_storage_network is defined %}
121+
data "openstack_networking_network_v2" "cluster_storage" {
122+
name = "{{ cluster_storage_network }}"
123+
}
124+
{% endif %}
125+
119126
data "openstack_networking_subnet_ids_v2" "cluster_external_subnets" {
120127
network_id = "${data.openstack_networking_network_v2.cluster_external_network.id}"
121128
}
@@ -177,6 +184,11 @@ data "openstack_networking_subnet_v2" "cluster_subnet" {
177184
##### Cluster ports
178185
#####
179186

187+
###
188+
# Login node
189+
###
190+
191+
# Primary network
180192
resource "openstack_networking_port_v2" "login" {
181193
name = "{{ cluster_name }}-login-0"
182194
network_id = "${data.openstack_networking_network_v2.cluster_network.id}"
@@ -193,14 +205,31 @@ resource "openstack_networking_port_v2" "login" {
193205

194206
binding {
195207
vnic_type = "{{ cluster_vnic_type | default('normal') }}"
196-
{% if cluster_vnic_profile is defined %}
197-
profile = <<EOF
198-
{{ cluster_vnic_profile | to_json }}
199-
EOF
200-
{% endif %}
201208
}
202209
}
203210

211+
# Storage network
212+
{% if cluster_storage_network is defined %}
213+
resource "openstack_networking_port_v2" "login_storage" {
214+
name = "{{ cluster_name }}-login-storage-0"
215+
network_id = data.openstack_networking_network_v2.cluster_storage.id
216+
admin_state_up = "true"
217+
218+
security_group_ids = [
219+
"${openstack_networking_secgroup_v2.secgroup_slurm_cluster.id}",
220+
]
221+
222+
binding {
223+
vnic_type = "{{ cluster_storage_vnic_type | default('normal') }}"
224+
}
225+
}
226+
{% endif %}
227+
228+
###
229+
# Control node
230+
###
231+
232+
# Primary network
204233
resource "openstack_networking_port_v2" "control" {
205234
name = "{{ cluster_name }}-control-0"
206235
network_id = "${data.openstack_networking_network_v2.cluster_network.id}"
@@ -216,15 +245,32 @@ resource "openstack_networking_port_v2" "control" {
216245

217246
binding {
218247
vnic_type = "{{ cluster_vnic_type | default('normal') }}"
219-
{% if cluster_vnic_profile is defined %}
220-
profile = <<EOF
221-
{{ cluster_vnic_profile | to_json }}
222-
EOF
223-
{% endif %}
248+
249+
}
250+
}
251+
252+
# Storage network
253+
{% if cluster_storage_network is defined %}
254+
resource "openstack_networking_port_v2" "control_storage" {
255+
name = "{{ cluster_name }}-control-storage-0"
256+
network_id = data.openstack_networking_network_v2.cluster_storage.id
257+
admin_state_up = "true"
258+
259+
security_group_ids = [
260+
"${openstack_networking_secgroup_v2.secgroup_slurm_cluster.id}"
261+
]
262+
263+
binding {
264+
vnic_type = "{{ cluster_storage_vnic_type | default('normal') }}"
224265
}
225266
}
267+
{% endif %}
226268

269+
###
270+
# Workers
271+
###
227272
{% for partition in openhpc_slurm_partitions %}
273+
# Primary network
228274
resource "openstack_networking_port_v2" "{{ partition.name }}" {
229275
count = {{ partition.count }}
230276
name = "{{ cluster_name }}-compute-{{ partition.name }}-${count.index}"
@@ -241,14 +287,27 @@ resource "openstack_networking_port_v2" "{{ partition.name }}" {
241287

242288
binding {
243289
vnic_type = "{{ cluster_vnic_type | default('normal') }}"
244-
{% if cluster_vnic_profile is defined %}
245-
profile = <<EOF
246-
{{ cluster_vnic_profile | to_json }}
247-
EOF
248-
{% endif %}
249290
}
250291
}
251292

293+
# Storage network
294+
{% if cluster_storage_network is defined %}
295+
resource "openstack_networking_port_v2" "{{ partition.name }}_storage" {
296+
count = {{ partition.count }}
297+
name = "{{ cluster_name }}-compute-{{ partition.name }}-storage-${count.index}"
298+
network_id = data.openstack_networking_network_v2.cluster_storage.id
299+
admin_state_up = "true"
300+
301+
security_group_ids = [
302+
"${openstack_networking_secgroup_v2.secgroup_slurm_cluster.id}"
303+
]
304+
305+
binding {
306+
vnic_type = "{{ cluster_storage_vnic_type | default('normal') }}"
307+
}
308+
}
309+
{% endif %}
310+
252311
{% endfor %}
253312

254313
#####
@@ -274,9 +333,15 @@ resource "openstack_compute_instance_v2" "login" {
274333
{% endif %}
275334

276335
network {
277-
port = "${openstack_networking_port_v2.login.id}"
336+
port = openstack_networking_port_v2.login.id
278337
}
279338

339+
{% if cluster_storage_network is defined %}
340+
network {
341+
port = openstack_networking_port_v2.login_storage.id
342+
}
343+
{% endif %}
344+
280345
# root device:
281346
block_device {
282347
uuid = "{{ cluster_image }}"
@@ -317,9 +382,15 @@ resource "openstack_compute_instance_v2" "control" {
317382
{% endif %}
318383

319384
network {
320-
port = "${openstack_networking_port_v2.control.id}"
385+
port = openstack_networking_port_v2.control.id
321386
}
322387

388+
{% if cluster_storage_network is defined %}
389+
network {
390+
port = openstack_networking_port_v2.control_storage.id
391+
}
392+
{% endif %}
393+
323394
# root device:
324395
block_device {
325396
uuid = "{{ cluster_image }}"
@@ -393,6 +464,12 @@ resource "openstack_compute_instance_v2" "{{ partition.name }}" {
393464
port = openstack_networking_port_v2.{{ partition.name }}[count.index].id
394465
}
395466

467+
{% if cluster_storage_network is defined %}
468+
network {
469+
port = openstack_networking_port_v2.{{ partition.name }}_storage[count.index].id
470+
}
471+
{% endif %}
472+
396473
# root device:
397474
block_device {
398475
uuid = "{{ cluster_image }}"

0 commit comments

Comments
 (0)