Skip to content

Commit e1bdb58

Browse files
committed
WIP: add lustre role
1 parent 8213ddb commit e1bdb58

File tree

11 files changed

+181
-3
lines changed

11 files changed

+181
-3
lines changed

ansible/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ roles/*
5858
!roles/squid/**
5959
!roles/tuned/
6060
!roles/tuned/**
61-
61+
!roles/lustre/
62+
!roles/lustre/**

ansible/fatimage.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
name: stackhpc.os-manila-mount
4545
tasks_from: install.yml
4646
when: "'manila' in group_names"
47+
- name: Install Lustre packages
48+
include_role:
49+
name: lustre
50+
tasks_from: install.yml
51+
when: "'lustre' in group_names"
4752

4853
- import_playbook: extras.yml
4954

ansible/filesystems.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@
2424
tasks:
2525
- include_role:
2626
name: stackhpc.os-manila-mount
27+
28+
- name: Setup Lustre clients
29+
hosts: lustre
30+
become: true
31+
tags: lustre
32+
tasks:
33+
- include_role:
34+
name: lustre
35+
tasks_from: configure.yml

ansible/roles/lustre/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# lustre
2+
3+
Install and configure a Lustre client. This builds RPM packages from source.
4+
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.
7+
8+
## Role Variables
9+
10+
- `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
11+
- `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`.
17+
18+
The following variables control the package build and and install and should not generally be required:
19+
- `lustre_build_packages`: Optional list. Prerequisite packages required to build Lustre. See `defaults/main.yml`.
20+
- `lustre_build_dir`: Optional str. Path to build lustre at, default `/tmp/lustre-release`.
21+
- `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`.
22+
- `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.
23+
- `lustre_cleanup_build`: Optional bool. Whether to uninstall prerequisite packages and delete the build directories etc. Default `true`.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
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
5+
lustre_mount_state: mounted
6+
7+
# below variables are for build and should not generally require changes
8+
lustre_build_packages:
9+
- "kernel-devel-{{ ansible_kernel }}"
10+
- git
11+
- gcc
12+
- libtool
13+
- python3
14+
- python3-devel
15+
- openmpi
16+
- elfutils-libelf-devel
17+
- libmount-devel
18+
- libnl3-devel
19+
- libyaml-devel
20+
- rpm-build
21+
- kernel-abi-stablelists
22+
- libaio
23+
- libaio-devel
24+
lustre_build_dir: /tmp/lustre-release
25+
lustre_configure_opts:
26+
- --disable-server
27+
- --with-linux=/usr/src/kernels/*
28+
- --with-o2ib=/usr/src/ofa_kernel/default
29+
- --disable-maintainer-mode
30+
- --disable-gss-keyring
31+
- --enable-mpitests=no
32+
lustre_rpm_globs: # NB: order is important here, as not installing from a repo
33+
- "kmod-lustre-client-{{ lustre_version }}-*"
34+
- "lustre-client-{{ lustre_version }}-*"
35+
lustre_cleanup_build: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# TODO: is this an ok way of doing it?
2+
- name: Mount lustre filesystem
3+
mount:
4+
fstype: lustre
5+
src: "{{ lustre_mgs_nid }}:/{{ lustre_fs_name }}"
6+
path: "{{ lustre_mount_point }}"
7+
state: "{{ lustre_mount_state }}"
8+
opts: "defaults,_netdev,noauto,x-systemd.automount,x-systemd.requires=lnet.service"
9+
# opts are systemd defaults from http://wiki.lustre.org/Mounting_a_Lustre_File_System_on_Client_Nodes
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
- name: Install lustre build prerequisites
2+
ansible.builtin.dnf:
3+
name: "{{ lustre_build_packages }}"
4+
register: _lustre_dnf_build_packages
5+
6+
- name: Clone lustre git repo
7+
ansible.builtin.git:
8+
repo: git://git.whamcloud.com/fs/lustre-release.git
9+
dest: "{{ lustre_build_dir }}"
10+
version: "{{ lustre_version }}"
11+
12+
- name: Prepare for lustre configuration
13+
ansible.builtin.command:
14+
cmd: ./autogen.sh
15+
chdir: "{{ lustre_build_dir }}"
16+
17+
- name: Configure lustre build
18+
ansible.builtin.command:
19+
cmd: "./configure {{ lustre_configure_opts | join(' ') }}"
20+
chdir: "{{ lustre_build_dir }}"
21+
22+
- name: Build lustre
23+
ansible.builtin.command:
24+
cmd: make rpms
25+
chdir: "{{ lustre_build_dir }}"
26+
27+
- name: Find rpms
28+
ansible.builtin.find:
29+
paths: "{{ lustre_build_dir }}"
30+
patterns: "{{ lustre_rpm_globs }}"
31+
use_regex: false
32+
register: _lustre_find_rpms
33+
34+
- name: Check rpms found
35+
assert:
36+
that: _lustre_find_rpms.files | length
37+
fail_msg: "No lustre repos found with lustre_rpm_globs = {{ lustre_rpm_globs }}"
38+
39+
- name: Install lustre rpms
40+
ansible.builtin.dnf:
41+
name: "{{ _lustre_find_rpms.files | map(attribute='path')}}"
42+
disable_gpg_check: yes
43+
44+
- block:
45+
- name: Remove lustre build prerequisites
46+
# NB only remove ones this role installed!
47+
ansible.builtin.dnf:
48+
name: "{{ item | regex_replace('Installed: ', '') }}"
49+
state: absent
50+
loop: "{{ _lustre_dnf_build_packages.results }}"
51+
52+
- name: Delete lustre build dir
53+
file:
54+
path: "{{ lustre_build_dir }}"
55+
state: absent
56+
when: lustre_cleanup_build | bool
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- name: Assert using RockyLinux 9
2+
assert:
3+
that: ansible_distribution_major_version | int == 9
4+
fail_msg: The 'lustre' role requires RockyLinux 9
5+
6+
- name: Check kernel-devel package is installed
7+
command: "dnf list --installed kernel-devel-{{ ansible_kernel }}"
8+
changed_when: false
9+
# NB: we don't check here the kernel will remain the same after reboot etc, see ofed/install.yml
10+
11+
- name: Ensure SELinux in permissive mode
12+
assert:
13+
that: selinux_state in ['permissive', 'disabled']
14+
fail_msg: "SELinux must be permissive for Lustre not '{{ selinux_state }}'; see variable selinux_state"
15+
16+
- name: Ensure lustre_mgs_nid is defined
17+
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
20+
loop: "{{ lustre_mounts }}"
21+
22+
- name: Ensure lustre_fs_name is defined
23+
assert:
24+
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
26+
loop: "{{ lustre_mounts }}"

ansible/validate.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,11 @@
9595
- import_role:
9696
name: freeipa
9797
tasks_from: validate.yml
98+
99+
- name: Validate lustre configuration
100+
hosts: lustre
101+
tags: lustre
102+
tasks:
103+
- import_role:
104+
name: lustre
105+
tasks_from: validate.yml

environments/common/inventory/groups

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,7 @@ freeipa_client
134134
# Hosts to run TuneD configuration
135135

136136
[ansible_init]
137-
# Hosts to run linux-anisble-init
137+
# Hosts to run linux-anisble-init
138+
139+
[lustre]
140+
# Hosts to run lustre client

0 commit comments

Comments
 (0)