Feat: add network share to nas

This commit is contained in:
2022-06-02 15:31:12 +02:00
parent 8f96cf6028
commit 9221790ca0
12 changed files with 96 additions and 30 deletions

View File

@@ -0,0 +1,7 @@
---
# defaults file for nfs_server
shares:
- mount_point: /media/nfs/default
server: test.lan
export: /test
options: defaults

View File

@@ -0,0 +1,4 @@
---
# handlers file for nfs_server
- name: reload nfs
command: 'exportfs -ra'

View File

@@ -0,0 +1,7 @@
---
- name: Debian - Install nfs
apt:
name:
- nfs-common
- nfs-kernel-server
state: present

View File

@@ -0,0 +1,23 @@
---
# tasks file for nfs_server
- name: Install os-specific packages
include_tasks: "{{ ansible_os_family | lower }}.yml"
- name: Ensure directories to export exist
file: # noqa 208
path: "{{ item.src }}"
state: directory
with_items: "{{ nfs_exports }}"
- name: Copy exports file.
template:
src: exports.j2
dest: /etc/exports
owner: root
group: root
mode: 0644
notify: reload nfs
- name: Ensure nfs is running.
service: "name=nfs-kernel-server state=started enabled=yes"
when: nfs_exports|length

View File

@@ -0,0 +1,13 @@
# /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)
#
{% for export in nfs_exports %}
{{ export.src }} {{ export.allowedIP }}({{ export.options }})
{% endfor %}

View File

@@ -0,0 +1,2 @@
localhost

View File

@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- nfs_server

View File

@@ -0,0 +1,2 @@
---
# vars file for nfs_server