Ansible role for installing and configuring a NFS server
- Jinja 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
ci/woodpecker/push/linting Pipeline was successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
| .woodpecker | ||
| defaults | ||
| handlers | ||
| meta | ||
| tasks | ||
| templates | ||
| .ansible-lint | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .markdownlint-cli2.jsonc | ||
| .sops.yaml | ||
| .yamllint | ||
| ansible.cfg | ||
| readme.md | ||
| renovate.json | ||
Ansible Role: NFS Server
Installs the kernel NFS server and manages /etc/exports together with the exported directories.
Requirements
Debian-family hosts (the install task uses apt and is guarded by os_family == "Debian"). The role needs root and
a systemd-based host.
Dependencies
None (dependencies: []).
Variables
| Variable | Required | Default | Description |
|---|---|---|---|
shares |
No | one example share (*) | List of NFS shares to export |
(*) The default is a single placeholder share: /srv/nfs/example exported to 10.0.0.1 with
rw,no_root_squash,no_subtree_check. Always override shares in your inventory.
Share keys
| Key | Required | Default | Description |
|---|---|---|---|
name |
Yes | Description of the share (written as a comment) | |
path |
Yes | Directory to export (created if missing) | |
client_ip |
Yes | Client IP address or network | |
client_options |
Yes | NFS export options | |
owner |
No | root |
Owner of the directory |
group |
No | root |
Group of the directory |
mode |
No | 0770 |
Mode of the directory |
Example
shares:
# production data
- name: "production data"
path: "/srv/nfs/production"
client_ip: "10.0.0.0/24"
client_options: "rw,sync,no_subtree_check"
owner: "nobody"
group: "nogroup"
mode: "0775"
# backup storage
- name: "backup storage"
path: "/srv/nfs/backups"
client_ip: "10.0.1.100"
client_options: "rw,no_root_squash,no_subtree_check"
owner: "backup"
group: "backup"
mode: "0700"
Usage
This repository has no playbook.yaml. The role (nfs_server) is consumed as a role by other playbooks, for
example the nfs-media and nfs-nextcloud repositories.
Operational notes
- Installs
nfs-kernel-serverand starts and enables thenfs-serverservice. - Creates every share directory, then renders
/etc/exportswith one line per share (<path> <client_ip>(<client_options>)). - The
exportfshandler runsexportfs -afwhen/etc/exportschanges. - Each share has a single client entry. Use a network in
client_ipto cover several clients.