From 3f491238fc2b22094196cea7c290f5d18997eb7f Mon Sep 17 00:00:00 2001 From: "Daniel A. Maierhofer" Date: Fri, 13 Jul 2018 01:10:50 +0200 Subject: [PATCH] Add ZFS sharenfs --- doc/ariane.md | 12 ++++++++++++ roles/ariane/tasks/zfs.yml | 26 ++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/doc/ariane.md b/doc/ariane.md index 206f5f7..7359562 100644 --- a/doc/ariane.md +++ b/doc/ariane.md @@ -90,13 +90,25 @@ rsync --stats -avhP --exclude-from=/var/tmp/ignorelist root@atlas:/home/ /zv1/ho rsync --stats -avhP --exclude Pictures root@atlas:/mnt/save/fet_daten/ /zv1/daten/ rsync --stats -avhP root@atlas:/mnt/save/fet_daten/Pictures/ /zv1/fotos/ ``` +### Share via NFS +```shell +zfs set sharenfs="rw=@192.168.86.0/24,insecure,sync,no_subtree_check,root_squash,no_wdelay" zv1/homes +zfs set sharenfs="rw=@192.168.86.0/24,insecure,sync,no_subtree_check,root_squash,crossmnt" zv1/daten +zfs set sharenfs="rw=@192.168.86.0/24,insecure,sync,no_subtree_check,root_squash,crossmnt" zv1/fotos +showmount -e +``` ### Before reinstalling ```shell zfs export ``` ### After reinstalling ```shell +./ansible-playbook -i hosts/production site.yml --tags common --limit ariane +ssh ariane apt-get update && apt-get upgrade && reboot +./ansible-playbook -i hosts/production site.yml --tags zfs --limit ariane zfs import +zpool import zv1 +zfs mount -a ``` ## ZFS Maintenance ```shell diff --git a/roles/ariane/tasks/zfs.yml b/roles/ariane/tasks/zfs.yml index 8e6980f..e281417 100644 --- a/roles/ariane/tasks/zfs.yml +++ b/roles/ariane/tasks/zfs.yml @@ -30,11 +30,29 @@ notify: zfs restart - name: zfs - set quota - zfs: "name={{ item }} state=present quota=1T" + zfs: + name: "{{ item.name }}" + state: present + extra_zfs_properties: + quota: "{{ item.quota }}" with_items: - - zv1/homes - - zv1/daten - - zv1/fotos + - { name: zv1/homes, quota: "1T" } + - { name: zv1/daten, quota: "1T" } + - { name: zv1/fotos, quota: "1T" } + +- name: zfs - install nfs-kernel-server + package: name=nfs-kernel-server + +- name: zfs - sharenfs + zfs: + name: "{{ item.name }}" + state: present + extra_zfs_properties: + sharenfs: "{{ item.opts }}" + with_items: + - { name: zv1/homes, opts: "rw=@192.168.86.0/24,insecure,sync,no_subtree_check,root_squash,no_wdelay" } + - { name: zv1/daten, opts: "rw=@192.168.86.0/24,insecure,sync,no_subtree_check,root_squash,crossmnt" } + - { name: zv1/fotos, opts: "rw=@192.168.86.0/24,insecure,sync,no_subtree_check,root_squash,crossmnt" } - name : zfs - zfs_mount.sh copy: src=zfs_mount.sh dest=/usr/local/bin/ owner=root group=root mode=0755