Created
December 18, 2025 08:56
-
-
Save nlgranger/b835a1a77985a85ace3dcbeaef56791e to your computer and use it in GitHub Desktop.
Ansible playbook for nfs over rdma on linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - name: Install NFS packages | |
| become: true | |
| ansible.builtin.apt: | |
| name: | |
| - nfs-kernel-server | |
| - rdma-core | |
| - ibverbs-utils | |
| - infiniband-diags | |
| - libibverbs-dev | |
| cache_valid_time: 86400 | |
| - name: Load rpcrdma module | |
| become: true | |
| community.general.modprobe: | |
| name: rpcrdma | |
| persistent: present | |
| - name: Create NFS exports | |
| become: true | |
| ansible.builtin.copy: | |
| dest: "/etc/exports" | |
| content: | | |
| /storage/home *(rw,no_subtree_check,no_root_squash,async,crossmnt,insecure) | |
| mode: "0644" | |
| notify: Reload NFS | |
| - name: Configure nfs.conf rdma | |
| become: true | |
| community.general.ini_file: | |
| path: /etc/nfs.conf | |
| section: nfsd | |
| option: rdma | |
| value: nfsrdma # not "y" ? | |
| notify: Reload NFS | |
| - name: Configure nfs rdma port | |
| # equivalent to run `echo "rdma 20049" > /proc/fs/nfsd/portlist` | |
| become: true | |
| ansible.builtin.lineinfile: | |
| path: /etc/default/nfs-kernel-server | |
| regexp: "^RPCNFSDOPTS=.*" | |
| line: RPCNFSDOPTS="--rdma=20049" | |
| notify: Reload NFS | |
| - name: Enable NFS service | |
| become: true | |
| ansible.builtin.service: | |
| name: nfs-server | |
| enabled: true | |
| state: started | |
| - name: Open NFS ports | |
| become: true | |
| community.general.ufw: | |
| rule: allow | |
| port: "{{ item.port }}" | |
| proto: "{{ item.proto }}" | |
| interface: "{{ item.interface }}" | |
| direction: "in" | |
| loop: | |
| - { port: 2049, proto: "tcp", interface: "lan" } | |
| - { port: 2049, proto: "udp", interface: "lan" } | |
| - { port: 2049, proto: "tcp", interface: "ib" } | |
| - { port: 2049, proto: "udp", interface: "ib" } | |
| - { port: 20049, proto: "udp", interface: "ib" } | |
| - { port: 20049, proto: "tcp", interface: "ib" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment