From d5a8dc1066615935b6de278b31d7007e7a6c4597 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 23 May 2020 04:02:28 +0200 Subject: add role zfs sanoid --- dan/sk-tomnext.yml | 2 ++ inventory/host_vars/sk-tomnext.yml | 17 ++++++++++++++--- roles/zfs/sanoid/defaults/main.yml | 26 ++++++++++++++++++++++++++ roles/zfs/sanoid/tasks/main.yml | 15 +++++++++++++++ roles/zfs/sanoid/templates/sanoid.conf.j2 | 22 ++++++++++++++++++++++ 5 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 roles/zfs/sanoid/defaults/main.yml create mode 100644 roles/zfs/sanoid/tasks/main.yml create mode 100644 roles/zfs/sanoid/templates/sanoid.conf.j2 diff --git a/dan/sk-tomnext.yml b/dan/sk-tomnext.yml index 1aa9baa9..4294880d 100644 --- a/dan/sk-tomnext.yml +++ b/dan/sk-tomnext.yml @@ -9,6 +9,8 @@ - role: apt-repo/base - role: cryptdisk - role: zfs/base + - role: apt-repo/spreadspace + - role: zfs/sanoid - role: vm/host - role: installer/debian/base tasks: diff --git a/inventory/host_vars/sk-tomnext.yml b/inventory/host_vars/sk-tomnext.yml index 840de6f6..d570f1b2 100644 --- a/inventory/host_vars/sk-tomnext.yml +++ b/inventory/host_vars/sk-tomnext.yml @@ -46,11 +46,22 @@ cryptdisk_volumes: device: /dev/disk/by-id/nvme-eui.00000000000000018ce38e0500157b3d-part3 +zfs_arc_size: + min: "{{ 2 * 1024 * 1024 * 1024 }}" + max: "{{ 8 * 1024 * 1024 * 1024 }}" + zfs_zpools: storage: mountpoint: /srv/storage create_vdevs: mirror /dev/mapper/crypto-nvme0 /dev/mapper/crypto-nvme1 -zfs_arc_size: - min: "{{ 2 * 1024 * 1024 * 1024 }}" - max: "{{ 8 * 1024 * 1024 * 1024 }}" + +zfs_sanoid_modules: + storage/docker: + use_template: ignore + storage/kubelet: + use_template: ignore + storage/vm: + use_template: production + recursive: yes + process_children_only: yes diff --git a/roles/zfs/sanoid/defaults/main.yml b/roles/zfs/sanoid/defaults/main.yml new file mode 100644 index 00000000..55ebbd9d --- /dev/null +++ b/roles/zfs/sanoid/defaults/main.yml @@ -0,0 +1,26 @@ +--- +zfs_sanoid_modules: {} + +zfs_sanoid_templates: + production: + frequently: 0 + hourly: 36 + daily: 7 + monthly: 0 + yearly: 0 + autosnap: yes + autoprune: yes + + backup: + frequently: 0 + hourly: 0 + daily: 60 + monthly: 6 + yearly: 0 + autosnap: no + autoprune: yes + + ignore: + autoprune: no + autosnap: no + monitor: no diff --git a/roles/zfs/sanoid/tasks/main.yml b/roles/zfs/sanoid/tasks/main.yml new file mode 100644 index 00000000..e35190e9 --- /dev/null +++ b/roles/zfs/sanoid/tasks/main.yml @@ -0,0 +1,15 @@ +--- +- name: install sanoid + apt: + name: sanoid + state: present + +- name: create sanoid config directory + file: + path: /etc/sanoid + state: directory + +- name: genarate sanoid config + template: + src: sanoid.conf.j2 + dest: /etc/sanoid/sanoid.conf diff --git a/roles/zfs/sanoid/templates/sanoid.conf.j2 b/roles/zfs/sanoid/templates/sanoid.conf.j2 new file mode 100644 index 00000000..2f2b29b4 --- /dev/null +++ b/roles/zfs/sanoid/templates/sanoid.conf.j2 @@ -0,0 +1,22 @@ +############################### +## modules +############################### +{% for name,options in zfs_sanoid_modules.items() %} + +[{{ name }}] +{% for option,value in options.items() %} + {{ option }} = {{ value }} +{% endfor %} +{% endfor %} + + +############################### +## templates +############################### +{% for name,options in zfs_sanoid_templates.items() %} + +[template_{{ name }}] +{% for option,value in options.items() %} + {{ option }} = {{ value }} +{% endfor %} +{% endfor %} -- cgit v1.2.3