Skip to content

Commit 410e0ed

Browse files
committed
allow definition of multiple lustre_mounts
1 parent e1bdb58 commit 410e0ed

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

ansible/roles/lustre/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Install and configure a Lustre client. This builds RPM packages from source.
99

1010
- `lustre_version`: Optional str. Version of lustre to build, default '2.15.64'. TODO: EXPLAIN. See https://wiki.whamcloud.com/display/PUB/Lustre+Support+Matrix
1111
- `lustre_mounts`: Optional list. Define Lustre filesystems and mountpoints as a list of dicts with possible keys:
12-
- `lustre_mgs_nid`: The NID for the MGS, e.g. `192.168.227.11@tcp1`
13-
- `lustre_fs_name`: The name of the filesystem to mount
14-
- `lustre_mount_point`: Path to mount filesystem at. Default is `/mnt/lustre/{{ lustre_fs_name}}`
15-
- `lustre_mount_state`: Mountpoint state, as for [ansible.posix.mount](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-state). Default `mounted`.
16-
These parameters may alternatively be specified as role variables of the same name, which are lower-priority than entries in `lustre_mounts`.
12+
- `mgs_nid`: The NID for the MGS, e.g. `192.168.227.11@tcp1`
13+
- `fs_name`: The name of the filesystem to mount
14+
- `mount_point`: Path to mount filesystem at. Default is `/mnt/lustre/{{ lustre_fs_name}}`
15+
- `mount_state`: Mountpoint state, as for [ansible.posix.mount](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-state). Default `mounted`.
16+
These parameters may alternatively be specified as role variables prefixed `lustre_`, which are lower-priority than entries in `lustre_mounts`.
1717

1818
The following variables control the package build and and install and should not generally be required:
1919
- `lustre_build_packages`: Optional list. Prerequisite packages required to build Lustre. See `defaults/main.yml`.

ansible/roles/lustre/defaults/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
lustre_version: 'b2_15' # TODO: FIXME to 2.15.5 on release see http://lists.lustre.org/pipermail/lustre-discuss-lustre.org/2024-June/019163.html
3-
lustre_mounts: []
4-
lustre_mount_point: /mnt/lustre
3+
lustre_mounts: [{}] # Ensures if all top-level vars are provided then this isn't required
4+
#lustre_mgs_nid:
5+
#lustre_fs_name:
6+
lustre_mount_point: "/mnt/lustre/{{ lustre_fs_name }}"
57
lustre_mount_state: mounted
68

79
# below variables are for build and should not generally require changes
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
- name: Ensure mount points exist
2+
ansible.builtin.file:
3+
path: "{{ item.mount_point | default(lustre_mount_point) }}/{{ item.fs_name | default(lustre_fs_name) }}"
4+
state: directory
5+
loop: "{{ lustre_mounts }}"
6+
when: "item.mount_state | default(lustre_mount_state) != 'absent'"
7+
# TODO: do we need to set owner/group/mode either pre- or post-mount?
8+
19
# TODO: is this an ok way of doing it?
210
- name: Mount lustre filesystem
3-
mount:
11+
ansible.posix.mount:
412
fstype: lustre
5-
src: "{{ lustre_mgs_nid }}:/{{ lustre_fs_name }}"
6-
path: "{{ lustre_mount_point }}"
13+
src: "{{ item.mgs_nid | default(lustre_mgs_nid) }}:/{{ item.lustre_fs_name | default(lustre_fs_name) }}"
14+
path: "{{ item.mount_point | default(lustre_mount_point) }}/{{ item.fs_name | default(lustre_fs_name) }}"
715
state: "{{ lustre_mount_state }}"
816
opts: "defaults,_netdev,noauto,x-systemd.automount,x-systemd.requires=lnet.service"
917
# opts are systemd defaults from http://wiki.lustre.org/Mounting_a_Lustre_File_System_on_Client_Nodes
18+
loop: "{{ lustre_mounts }}"

ansible/roles/lustre/tasks/validate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
- name: Ensure lustre_mgs_nid is defined
1717
assert:
18-
that: item.lustre_mgs_nid | default(lustre_mgs_nid) is defined
19-
fail_msg: lustre_mgs_nid must be defined or specified in lustre_mounts elements
18+
that: item.mgs_nid | default(lustre_mgs_nid) is defined
19+
fail_msg: lustre_mounts entries must specify mgs_nid or lustre_mgs_nid must be defined
2020
loop: "{{ lustre_mounts }}"
2121

2222
- name: Ensure lustre_fs_name is defined
2323
assert:
2424
that: item.lustre_fs_name | default(lustre_fs_name) is defined
25-
fail_msg: lustre_fs_name must be defined or specified in lustre_mounts elements
25+
fail_msg: lustre_mounts entries must specify fs_name or lustre_fs_name must be specified
2626
loop: "{{ lustre_mounts }}"

0 commit comments

Comments
 (0)