Ansible role for installing and configuring a NFS server
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Simon Cornet 4ae674acc4
All checks were successful
ci/woodpecker/push/linting Pipeline was successful
docs: improve readme
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-05 17:28:30 +02:00
.woodpecker chore(package): update cr.simoncor.net/dockerhub/davidanson/markdownlint-cli2 docker tag to v0.23.3 2026-09-20 05:49:19 +00:00
defaults feat: initial commit 2026-04-07 16:26:05 +02:00
handlers feat: initial commit 2026-04-07 16:26:05 +02:00
meta feat: add meta 2026-04-07 16:53:44 +02:00
tasks chore: migrate bare ansible_* facts to ansible_facts[] syntax 2026-05-19 09:19:06 +02:00
templates feat: add whiteline between shares for readibility 2026-04-07 17:08:51 +02:00
.ansible-lint fix: exclude only sops yml files from lint 2026-07-14 16:23:48 +02:00
.editorconfig chore: add .editorconfig and .gitattributes 2026-05-27 14:23:53 +02:00
.gitattributes chore: add .editorconfig and .gitattributes 2026-05-27 14:23:53 +02:00
.gitignore feat: initial commit 2026-04-07 16:26:05 +02:00
.markdownlint-cli2.jsonc style: ignore line length for markdown tables 2026-05-15 13:44:00 +02:00
.sops.yaml fix: correct sops regex to ya?ml 2026-07-14 16:01:55 +02:00
.yamllint chore: exclude .yml files from lint configs 2026-07-14 16:17:31 +02:00
ansible.cfg chore: sync linting and config files from common 2026-07-14 11:33:15 +02:00
readme.md docs: improve readme 2026-10-05 17:28:30 +02:00
renovate.json feat: initial commit 2026-04-07 16:26:05 +02:00

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-server and starts and enables the nfs-server service.
  • Creates every share directory, then renders /etc/exports with one line per share (<path> <client_ip>(<client_options>)).
  • The exportfs handler runs exportfs -af when /etc/exports changes.
  • Each share has a single client entry. Use a network in client_ip to cover several clients.