Skip to content

Commit

Permalink
Merge pull request NVIDIA#1100 from ajdecon/mofed-role
Browse files Browse the repository at this point in the history
Add a basic playbook for installing Mellanox OFED
  • Loading branch information
ajdecon authored Jun 6, 2022
2 parents 7e0b7d6 + b8bf790 commit 26aa7cf
Show file tree
Hide file tree
Showing 10 changed files with 178 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- openshift
- rsyslog_client
- rsyslog_server
- mofed
- singularity_wrapper
- slurm
- spack
Expand Down
12 changes: 12 additions & 0 deletions playbooks/utilities/mofed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Installs NVIDIA Mellanox OFED, a collection of software packages to enable
# high-speed networking with InfiniBand or RoCE on NVIDIA Mellanox networking
# adapters.
#
# This playbook automates the software installation process outlined in the
# MLNX_OFED documentation, here:
# https://community.mellanox.com/s/article/howto-install-mlnx-ofed-driver
---
- hosts: "{{ hostlist | default('all') }}"
become: yes
roles:
- mofed
11 changes: 11 additions & 0 deletions roles/mofed/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
mofed_version: "5.6-2.0.9.0"

mofed_download_dir: "/tmp/mofed-install"
mofed_download_dest: "mofed.tgz"
mofed_download_name: "MLNX_OFED_LINUX-{{ mofed_version }}-{{ mofed_distro }}{{ ansible_distribution_version }}-{{ ansible_architecture }}"
mofed_download_url: "http://www.mellanox.com/downloads/ofed/MLNX_OFED-{{ mofed_version }}/{{ mofed_download_name }}.tgz"

mofed_install_flags: "--all --without-fw-update"

mofed_cleanup_install_dir: true
7 changes: 7 additions & 0 deletions roles/mofed/molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include mofed"
include_role:
name: "mofed"
44 changes: 44 additions & 0 deletions roles/mofed/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: mofed-ubuntu-1804
image: geerlingguy/docker-ubuntu1804-ansible
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
command: /sbin/init
pre_build_image: true
privileged: true
- name: mofed-ubuntu-2004
image: geerlingguy/docker-ubuntu2004-ansible
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
command: /sbin/init
pre_build_image: true
privileged: true
- name: mofed-centos-7
image: geerlingguy/docker-centos7-ansible
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
command: /sbin/init
pre_build_image: true
privileged: true
- name: mofed-centos-8
image: geerlingguy/docker-centos8-ansible
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
command: /sbin/init
pre_build_image: true
privileged: true
provisioner:
name: ansible
ansible_args:
- -vv
inventory:
group_vars:
all:
mofed_install_flags: "--all --without-fw-update --user-space-only"
verifier:
name: ansible
10 changes: 10 additions & 0 deletions roles/mofed/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# This is an example playbook to execute Ansible tests.

- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Example assertion
assert:
that: true
69 changes: 69 additions & 0 deletions roles/mofed/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
- name: include vars if ubuntu
include_vars: ubuntu.yml
when: ansible_distribution == "Ubuntu"

- name: include vars if redhat-compatible
include_vars: rhel{{ ansible_distribution_major_version }}.yml
when: ansible_os_family == "RedHat"

- name: ensure perl is installed
package:
name: perl
state: present

- name: ensure rhel prereqs are installed
yum:
name: "{{ mofed_pkg_prereqs }}"
state: present
when: ansible_os_family == "RedHat"

- name: attempt to get installed ofed version # noqa risky-shell-pipe
shell: ofed_info | head -n1
register: ofed_info
changed_when: ofed_info.rc != 0

- name: default to skipping install
set_fact:
mofed_do_install: false

- name: check ofed version against desired version # noqa no-handler
set_fact:
mofed_do_install: true
when: ofed_info.changed or (mofed_version not in ofed_info.stdout)

- name: create download directory
file:
path: "{{ mofed_download_dir }}"
state: "directory"
owner: "root"
group: "root"
mode: "0755"
when: mofed_do_install

- name: download mofed distribution
get_url:
url: "{{ mofed_download_url }}"
dest: "{{ mofed_download_dir }}/{{ mofed_download_dest }}"
when: mofed_do_install

- name: extract mofed distribution
unarchive:
src: "{{ mofed_download_dir }}/{{ mofed_download_dest }}"
remote_src: true
dest: "{{ mofed_download_dir }}"
when: mofed_do_install

- name: execute mlnxofedinstall
shell:
cmd: yes | ./mlnxofedinstall {{ mofed_install_flags }}
chdir: "{{ mofed_download_dir }}/{{ mofed_download_name }}"
environment:
TERM: "xterm"
when: mofed_do_install

- name: clean up install dir
file:
path: "{{ mofed_download_dir }}"
state: "absent"
when: mofed_do_install and mofed_cleanup_install_dir
12 changes: 12 additions & 0 deletions roles/mofed/vars/rhel7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
mofed_distro: "rhel"
mofed_pkg_prereqs:
- pciutils-libs
- numactl-libs
- gcc-gfortran
- tcsh
- libusbx
- libnl3
- tcl
- fuse-libs
- tk
10 changes: 10 additions & 0 deletions roles/mofed/vars/rhel8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
mofed_distro: "rhel"
mofed_pkg_prereqs:
- tcsh
- gcc-gfortran
- numactl-libs
- kernel-modules-extra
- tcl
- tk
- fuse-libs
2 changes: 2 additions & 0 deletions roles/mofed/vars/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
mofed_distro: "ubuntu"

0 comments on commit 26aa7cf

Please sign in to comment.