Skip to content

Commit 5506876

Browse files
committed
refactor lustre role for multiple mounts, selectable lnet label
1 parent 37d727a commit 5506876

File tree

6 files changed

+43
-35
lines changed

6 files changed

+43
-35
lines changed

ansible/roles/lustre/README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22

33
Install and configure a Lustre client. This builds RPM packages from source.
44

5-
**NB:** The `install.yml` playbook in this role should only be run during image build, with the default `update_enable=true`. This ensures that the latest kernel and matching
6-
`kernel-devel` packages will be installed. This playbook is not idempotent.
5+
**NB:** The `install.yml` playbook in this role should only be run during image build and is not idempotent. This will install the `kernel-devel` package; if not already installed (e.g. from an `ofed` installation), this may require enabling update of DNF packages during build using `update_enable=true`, which will upgrade the kernel as well.
76

87
**NB:** Currently this only supports RockyLinux 9.
98

109
## Role Variables
1110

12-
- `lustre_version`: Optional str. Version of lustre to build, default '2.15.5' which is the first version with EL9 support
13-
- `lustre_mounts`: Required list. Define Lustre filesystems and mountpoints as a list of dicts with possible keys:
14-
- `mgs_nid`: The NID for the MGS, e.g. `192.168.227.11@tcp1`
15-
- `fs_name`: The name of the filesystem to mount
16-
- `mount_point`: Path to mount filesystem at. Default is `/mnt/lustre/{{ lustre_fs_name}}`
17-
- `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`.
18-
TODO: FIXME: Any of these parameters may alternatively be specified as role variables prefixed `lustre_`. If both are given entries in `lustre_mounts` take priority.
11+
- `lustre_version`: Optional str. Version of lustre to build, default `2.15.5` which is the first version with EL9 support
12+
- `lustre_lnet_label`: Optional str. The "lnet label" part of the host's NID, e.g. `tcp0` or `o2ib1`. Default `tcp`.
13+
- `lustre_mgs_nid`: Required str. The NID(s) for the MGS, e.g. `192.168.227.11@tcp1` (separate mutiple MGS NIDs using `:`).
14+
- `lustre_mounts`: Required list. Define Lustre filesystems and mountpoints as a list of dicts with keys:
15+
- `fs_name`: Required str. The name of the filesystem to mount
16+
- `mount_point`: Required str. Path to mount filesystem at.
17+
- `mount_state`: Optional mount state, as for [ansible.posix.mount](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-state). Default is `lustre_mount_state`.
18+
- `mount_options`: Optional mount options. Default is `lustre_mount_options`.
19+
- `lustre_mount_state`. Optional default mount state for all mounts, as for [ansible.posix.mount](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-state). Default is `mounted`.
20+
- `lustre_mount_options`. Optional default mount options. Default values are systemd defaults from [Lustre client docs](http://wiki.lustre.org/Mounting_a_Lustre_File_System_on_Client_Nodes).
21+
1922
The following variables control the package build and and install and should not generally be required:
2023
- `lustre_build_packages`: Optional list. Prerequisite packages required to build Lustre. See `defaults/main.yml`.
2124
- `lustre_build_dir`: Optional str. Path to build lustre at, default `/tmp/lustre-release`.
22-
- `lustre_configure_opts`: Optional list. Options to `./configure` command. Default builds client rpms supporting Mellnox OFED, without support for GSS keys. See `defaults/main.yml`.
25+
- `lustre_configure_opts`: Optional list. Options to `./configure` command. Default builds client rpms supporting Mellanox OFED, without support for GSS keys.
2326
- `lustre_rpm_globs`: Optional list. Shell glob patterns for rpms to install. Note order is important as the built RPMs are not in a yum repo. Default is just the `kmod-lustre-client` and `lustre-client` packages.
24-
- `lustre_cleanup_build`: Optional bool. Whether to uninstall prerequisite packages and delete the build directories etc. Default `true`.
27+
- `lustre_build_cleanup`: Optional bool. Whether to uninstall prerequisite packages and delete the build directories etc. Default `true`.

ansible/roles/lustre/defaults/main.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
lustre_version: '2.15.5' # https://www.lustre.org/lustre-2-15-5-released/
2+
lustre_lnet_label: tcp
23
#lustre_mgs_nid:
3-
lustre_fs_name: lustre
4-
lustre_mount_point: "/mnt/lustre/{{ lustre_fs_name }}"
4+
lustre_mounts: []
55
lustre_mount_state: mounted
6+
lustre_mount_options: 'defaults,_netdev,noauto,x-systemd.automount,x-systemd.requires=lnet.service'
67

78
# below variables are for build and should not generally require changes
89
lustre_build_packages:
@@ -32,4 +33,4 @@ lustre_configure_opts:
3233
lustre_rpm_globs: # NB: order is important here, as not installing from a repo
3334
- "kmod-lustre-client-{{ lustre_version | split('.') | first }}*" # only take part of the version as -RC versions produce _RC rpms
3435
- "lustre-client-{{ lustre_version | split('.') | first }}*"
35-
lustre_cleanup_build: true
36+
lustre_build_cleanup: true

ansible/roles/lustre/tasks/configure.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,23 @@
2929
name: lnet
3030
state: "{{ 'restarted' if _lnet_conf.changed else 'started' }}"
3131

32+
# TODO: on some nodes we've got additional nodes!
33+
# An systemd lnet restart fixed it
34+
3235
- name: Ensure mount points exist
3336
ansible.builtin.file:
34-
path: "{{ lustre_mount_point }}"
37+
path: "{{ item.mount_point }}"
3538
state: directory
36-
when: "lustre_mount_state != 'absent'"
39+
loop: "{{ lustre_mounts }}"
40+
when: "(item.mount_state | default(lustre_mount_state)) != 'absent'"
3741
# TODO: do we need to set owner/group/mode either pre- or post-mount?
3842

39-
# TODO: is this an ok way of doing it?
4043
- name: Mount lustre filesystem
4144
ansible.posix.mount:
4245
fstype: lustre
43-
src: "{{ lustre_mgs_nid }}:/{{ lustre_fs_name }}"
44-
path: "{{ lustre_mount_point }}"
45-
state: "{{ lustre_mount_state }}"
46-
opts: "defaults,_netdev,noauto,x-systemd.automount,x-systemd.requires=lnet.service"
47-
# opts are systemd defaults from http://wiki.lustre.org/Mounting_a_Lustre_File_System_on_Client_Nodes
46+
src: "{{ lustre_mgs_nid }}:/{{ item.fs_name }}"
47+
path: "{{ item.mount_point }}"
48+
state: "{{ (item.mount_state | default(lustre_mount_state)) }}"
49+
opts: "{{ item.mount_options | default(lustre_mount_options) }}"
50+
loop: "{{ lustre_mounts }}"
51+

ansible/roles/lustre/tasks/install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@
6767
file:
6868
path: "{{ lustre_build_dir }}"
6969
state: absent
70-
when: lustre_cleanup_build | bool
70+
when: lustre_build_cleanup | bool

ansible/roles/lustre/tasks/validate.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
that: selinux_state in ['permissive', 'disabled']
1414
fail_msg: "SELinux must be permissive for Lustre not '{{ selinux_state }}'; see variable selinux_state"
1515

16-
# TODO: fixme lustre_mounts
17-
# - name: Ensure lustre_mgs_nid is defined
18-
# assert:
19-
# that: item.mgs_nid | default(lustre_mgs_nid) is defined
20-
# fail_msg: lustre_mounts entries must specify mgs_nid or lustre_mgs_nid must be defined
21-
# loop: "{{ lustre_mounts }}"
16+
- name: Ensure lustre_mgs_nid is defined
17+
assert:
18+
that: lustre_mgs_nid is defined
19+
fail_msg: Variable lustre_mgs_nid must be defined
2220

23-
# - name: Ensure lustre_fs_name is defined
24-
# assert:
25-
# that: item.lustre_fs_name | default(lustre_fs_name) is defined
26-
# fail_msg: lustre_mounts entries must specify fs_name or lustre_fs_name must be specified
27-
# loop: "{{ lustre_mounts }}"
21+
- name: Ensure lustre_mounts entries define filesystem name and mount point
22+
assert:
23+
that:
24+
- item.fs_name is defined
25+
- item.mount_point is defined
26+
fail_msg: All lustre_mounts entries must specify fs_name and mount_point
27+
loop: "{{ lustre_mounts }}"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
net:
22
- net type: tcp1
33
local NI(s):
4-
- nid: {{ _lustre_ip }}@tcp1
4+
- nid: {{ _lustre_ip }}@{{ lustre_lnet_label }}
55
interfaces:
66
0: {{ _lustre_interface }}

0 commit comments

Comments
 (0)