Skip to content

Commit 6228aec

Browse files
Add option to mount NVMe's as a Logical volume
1 parent 86742e7 commit 6228aec

File tree

9 files changed

+114
-12
lines changed

9 files changed

+114
-12
lines changed

autoscaling/tf_init/bastion_update.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ resource "local_file" "inventory" {
4343
nfs_source_path = var.nfs_source_path,
4444
nfs_options = var.nfs_options,
4545
localdisk = var.localdisk,
46+
log_vol = var.log_vol,
47+
redundancy = var.redundancy,
4648
cluster_nfs_path = var.cluster_nfs_path,
4749
scratch_nfs_path = var.scratch_nfs_path,
4850
cluster_network = var.cluster_network,

autoscaling/tf_init/inventory.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ nfs_source_IP=${nfs_source_IP}
5555
nfs_source_path=${nfs_source_path}
5656
nfs_options=${nfs_options}
5757
localdisk=${localdisk}
58+
redundancy=${redundancy}
59+
log_vol=${log_vol}
5860
ldap=${ldap}
5961
queue=${queue}
6062
instance_type=${instance_type}

bastion.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ resource "null_resource" "cluster" {
207207
nfs_source_path = var.nfs_source_path,
208208
nfs_options = var.nfs_options,
209209
localdisk = var.localdisk,
210+
log_vol = var.log_vol,
211+
redundancy = var.redundancy,
210212
cluster_network = var.cluster_network,
211213
slurm = var.slurm,
212214
rack_aware = var.rack_aware,
@@ -362,6 +364,8 @@ resource "null_resource" "cluster" {
362364
nfs_source_path = var.nfs_source_path,
363365
nfs_options = var.nfs_options,
364366
localdisk = var.localdisk,
367+
log_vol = var.log_vol,
368+
redundancy = var.redundancy,
365369
monitoring = var.monitoring,
366370
hyperthreading = var.hyperthreading,
367371
unsupported = var.unsupported,

conf/variables.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,7 @@ variable "bastion_username" { default = "${bastion_username}" }
126126
variable "compute_username" { default = "${compute_username}" }
127127

128128
variable "localdisk" { default = "${localdisk}" }
129+
variable "log_vol" { default = "${log_vol}" }
130+
variable "redundancy" { default = "${redundancy}" }
129131

130132
variable "instance_pool_ocpus_denseIO_flex" { default = "##OCPU##"}

inventory.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ nfs_source_IP=${nfs_source_IP}
4747
nfs_source_path=${nfs_source_path}
4848
nfs_options=${nfs_options}
4949
localdisk=${localdisk}
50+
redundancy=${redundancy}
51+
log_vol=${log_vol}
5052
instance_pool_ocpus=${instance_pool_ocpus}
5153
queue=${queue}
5254
monitoring=${monitoring}
Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,94 @@
11
---
2+
- name: check path
3+
set_fact:
4+
nvme_path_edited: "{% if nvme_path[-1] == '/' %}{{nvme_path[:-1]}}{% else%}{{nvme_path}}{% endif %}"
5+
6+
- name: Get the number of NVMe's
7+
set_fact:
8+
nvme_count: "{{ hostvars[inventory_hostname]['ansible_devices'] | select('match','nvme[0-9]n1') | list | length}}"
9+
10+
- name: Create a LVM?
11+
set_fact:
12+
one_lv: "{{( log_vol | bool ) and ( ( nvme_count | int ) > 1 )}}"
13+
214
- name: Create a new primary partition
315
parted:
4-
device: /dev/nvme0n1
16+
device: "/dev/{{item}}"
517
number: 1
618
state: present
719
label: gpt
8-
when: "'nvme0n1' in hostvars[inventory_hostname].ansible_devices"
20+
with_items:
21+
- "{{ hostvars[inventory_hostname]['ansible_devices'] | select('match','nvme[0-9]n1') | list }}"
22+
923
- name: create a filesystem
1024
filesystem:
11-
dev: /dev/nvme0n1p1
25+
dev: "/dev/{{item}}p1"
1226
fstype: xfs
13-
opts: -L localscratch
14-
when: "'nvme0n1' in hostvars[inventory_hostname].ansible_devices"
27+
opts: "-L locscratch{{item | replace('nvme','') | replace('n1','')}}"
28+
with_items:
29+
- "{{ hostvars[inventory_hostname]['ansible_devices'] | select('match','nvme[0-9]n1') | list }}"
30+
when: not ( one_lv | bool )
31+
1532
- name: Mount local volume
1633
mount:
17-
path: "{{ nvme_path }}"
18-
src: LABEL=localscratch
34+
path: "{% if item | replace('nvme','') | replace('n1','') == '0' %}{{ nvme_path_edited}}{% else%}{{ nvme_path_edited}}{{item | replace('nvme','') | replace('n1','')}}{% endif %}"
35+
src: "LABEL=locscratch{{item | replace('nvme','') | replace('n1','')}}"
1936
fstype: xfs
2037
opts: defaults,noatime
2138
state: mounted
22-
when: "'nvme0n1' in hostvars[inventory_hostname].ansible_devices"
23-
- name: "set permissions on {{ nvme_path }}"
39+
with_items:
40+
- "{{ hostvars[inventory_hostname]['ansible_devices'] | select('match','nvme[0-9]n1') | list }}"
41+
when: not ( one_lv | bool )
42+
43+
- name: "set permissions on {{ nvme_path_edited }}"
2444
become: true
2545
file:
26-
path: "{{ nvme_path }}"
46+
path: "{% if item | replace('nvme','') | replace('n1','') == '0' %}{{ nvme_path_edited}}{% else%}{{ nvme_path_edited}}{{item | replace('nvme','') | replace('n1','')}}{% endif %}"
2747
state: directory
2848
owner: "{{ ansible_user }}"
2949
mode: 0775
3050
group: "{{privilege_group_name}}"
3151
recurse: no
32-
when: "'nvme0n1' in hostvars[inventory_hostname].ansible_devices"
52+
with_items:
53+
- "{{ hostvars[inventory_hostname]['ansible_devices'] | select('match','nvme[0-9]n1') | list }}"
54+
when: not ( one_lv | bool )
55+
56+
- name: Create volume group
57+
lvg:
58+
vg: "vg_nvmes"
59+
pvs: "{{['/dev/']|product(hostvars[inventory_hostname]['ansible_devices'] | select('match','nvme[0-9]n1') | list)|map('join', '') | join(',')}}"
60+
when: one_lv | bool
61+
62+
- name: Create Logical volume
63+
lvol:
64+
vg: "vg_nvmes"
65+
lv: "lv_nvmes"
66+
size: 100%FREE
67+
opts: "{% if redundancy | bool %}--type raid10{% else%}-i4{% endif %}"
68+
when: one_lv | bool
69+
70+
- name: Create file system
71+
filesystem:
72+
fstype: xfs
73+
dev: "/dev/vg_nvmes/lv_nvmes"
74+
when: one_lv | bool
75+
76+
- name: Mount local volume
77+
mount:
78+
path: "{{ nvme_path_edited}}"
79+
src: "/dev/vg_nvmes/lv_nvmes"
80+
fstype: xfs
81+
opts: defaults,noatime
82+
state: mounted
83+
when: one_lv | bool
84+
85+
- name: "set permissions on {{ nvme_path_edited }}"
86+
become: true
87+
file:
88+
path: "{{ nvme_path_edited}}"
89+
state: directory
90+
owner: "{{ ansible_user }}"
91+
mode: 0775
92+
group: "{{privilege_group_name}}"
93+
recurse: no
94+
when: one_lv | bool

schema.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ variableGroups:
138138
- ${cluster_block_volume_size}
139139
- ${cluster_block_volume_performance}
140140
- ${localdisk}
141+
- ${log_vol}
142+
- ${redundancy}
141143
- title: "Network options"
142144
variables:
143145
- ${use_existing_vcn}
@@ -1142,6 +1144,27 @@ variables:
11421144
description: "For nodes using a NVMe, mount the localdisk"
11431145
visible: ${use_advanced}
11441146

1147+
log_vol:
1148+
type: boolean
1149+
title: "One Logical Volume"
1150+
default: true
1151+
description: "Mount all NVMe's as one logical volume"
1152+
visible:
1153+
and:
1154+
- ${use_advanced}
1155+
- ${localdisk}
1156+
1157+
redundancy:
1158+
type: boolean
1159+
title: "Redundancy"
1160+
default: true
1161+
description: "Use RAID for redundancy"
1162+
visible:
1163+
and:
1164+
- ${use_advanced}
1165+
- ${localdisk}
1166+
- ${log_vol}
1167+
11451168
nfs_target_path:
11461169
type: string
11471170
title: "NFS Path"

slurm_ha.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ resource "null_resource" "cluster_backup" {
218218
nfs_source_path = var.nfs_source_path,
219219
nfs_options = var.nfs_options,
220220
localdisk = var.localdisk,
221+
log_vol = var.log_vol,
222+
redundancy = var.redundancy,
221223
cluster_network = var.cluster_network,
222224
slurm = var.slurm,
223225
slurm_nfs_path = var.slurm_nfs ? var.nfs_source_path : var.cluster_nfs_path,
@@ -373,6 +375,8 @@ resource "null_resource" "cluster_backup" {
373375
nfs_source_path = var.nfs_source_path,
374376
nfs_options = var.nfs_options,
375377
localdisk = var.localdisk,
378+
log_vol = var.log_vol,
379+
redundancy = var.redundancy,
376380
monitoring = var.monitoring,
377381
hyperthreading = var.hyperthreading,
378382
unsupported = var.unsupported,

variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ variable cluster_nfs_export {default = ""}
237237
variable "private_deployment" { default = false }
238238

239239
variable "localdisk" { default = true }
240-
240+
variable "log_vol" { default = false }
241+
variable "redundancy" { default = true }
241242

242243
variable "use_marketplace_image_login" { default = true}
243244
variable "use_old_marketplace_image_login" { default = false}

0 commit comments

Comments
 (0)