nfs server role

main
Ricard Illa 2023-01-11 11:55:10 +01:00
parent bda57660c2
commit d069a86e81
5 changed files with 87 additions and 0 deletions

View File

@ -36,6 +36,14 @@
roles: roles:
- mounts - mounts
- name: nfs-server
hosts:
- suricata
become: true
roles:
- nfs-server
tags: nfs
- name: usercfg - name: usercfg
hosts: hosts:
- suricata - suricata

View File

@ -140,6 +140,32 @@ all:
opts: "subvol=certs,noatime,compress=zstd" opts: "subvol=certs,noatime,compress=zstd"
passno: "0" passno: "0"
- src: "/mnt/certs/acme"
path: "/srv/nfs/k8s/acme"
fstype: "none"
opts: "bind"
passno: "0"
nfs_exports:
- path: "/srv/nfs"
hosts:
- hostname: localhost
options:
- ro
- all_squash
- no_subtree_check
- fsid=0
- path: "/srv/nfs/k8s"
hosts:
- hostname: localhost
options:
- rw
- no_root_squash
- no_subtree_check
- sync
- crossmnt
rpi_cfg: rpi_cfg:
- "enable_uart=1" - "enable_uart=1"
- "otg_mode=1" - "otg_mode=1"

View File

@ -0,0 +1,29 @@
---
- name: install nfs-utils with apk
apk:
name: nfs-utils
- name: set NFS's `NFS_NEEDED_SERVICES`
lineinfile:
path: /etc/conf.d/nfs
regexp: '^NFS_NEEDED_SERVICES='
line: 'NFS_NEEDED_SERVICES="rpc.idmapd"'
- name: set NFS's `OPTS_RPC_NFSD`
lineinfile:
path: /etc/conf.d/nfs
regexp: '^OPTS_RPC_NFSD='
line: 'OPTS_RPC_NFSD="8 -N 3 -V 4"'
- name: set NFS's `OPTS_RPC_MOUNTD`
lineinfile:
path: /etc/conf.d/nfs
regexp: '^OPTS_RPC_MOUNTD'
line: 'OPTS_RPC_MOUNTD="-N 3 -V 4"'
- name: start and enable nfs
service:
name: nfs
state: started
enabled: true

View File

@ -0,0 +1,16 @@
---
- name: render /etc/exports
template:
src: exports.j2
dest: /etc/exports
mode: '0644'
register: exports
- name: alpine-specific nfs server tasks
include_tasks: alpine.yml
when: ansible_distribution == "Alpine"
- name: export nfs exports
command: /usr/sbin/exportfs -arv
when: exports.changed

View File

@ -0,0 +1,8 @@
{% for export in nfs_exports %}
{{- export.path }}{% for host in export.hosts %}
{{ host.hostname }}({% for option in host.options -%}
{{- option }},
{%- endfor %})
{%- endfor %}
{% endfor %}