From 50cbea2abec48e4518ea6a112e4b5476fe88b54f Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Wed, 4 Mar 2020 16:20:20 +0100 Subject: [PATCH] Add state for NFS server --- states/nfsserver/exports | 15 +++++++++++++ states/nfsserver/init.sls | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 states/nfsserver/exports create mode 100644 states/nfsserver/init.sls diff --git a/states/nfsserver/exports b/states/nfsserver/exports new file mode 100644 index 0000000..d36f2a6 --- /dev/null +++ b/states/nfsserver/exports @@ -0,0 +1,15 @@ +# /etc/exports: the access control list for filesystems which may be exported +# to NFS clients. See exports(5). +# +# Example for NFSv2 and NFSv3: +# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) +# +# Example for NFSv4: +# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check) +# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check) +# + +{{ nfs_root }} *(rw,async,fsid=root,crossmnt,no_subtree_check) +{{ nfs_root }}/web web(rw,async,no_root_squash,no_subtree_check) +{{ nfs_root }}/mail mail(rw,async,no_subtree_check) migimap(rw,async,no_subtree_check) + diff --git a/states/nfsserver/init.sls b/states/nfsserver/init.sls new file mode 100644 index 0000000..c0e7afa --- /dev/null +++ b/states/nfsserver/init.sls @@ -0,0 +1,44 @@ +{% set nfs_root = salt['pillar.get']('nfsserver:nfsroot', '/srv/nfs4') -%} + +nfs-kernel-server: + pkg: + - installed + service: + - running + - enable: True + - require: + - pkg: nfs-kernel-server + +{{ nfs_root }}: + file.directory: + - user: root + - group: root + - mode: 0755 + +{{ nfs_root }}/mail: + file.directory: + - user: root + - group: root + - mode: 0751 + - require: + - file: {{ nfs_root }} + +{{ nfs_root }}/web: + file.directory: + - user: root + - group: root + - mode: 0751 + - require: + - file: {{ nfs_root }} + +/etc/exports: + file.managed: + - user: root + - group: root + - mode: 0644 + - template: jinja + - context: + nfs_root: {{ nfs_root }} + - source: salt://nfsserver/exports + - watch_in: + - service: nfs-kernel-server