summaryrefslogtreecommitdiff
path: root/roles/storage/zfs/sanoid
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-04-04 00:51:06 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-04-04 00:51:06 +0200
commit1f3ad3812836ed0f8f4f290346014821e6601c4d (patch)
tree0a973d531da3e61ae33e4ee79542f0ed69dabeb3 /roles/storage/zfs/sanoid
parentmove cryptdisk role to new storage subdir (diff)
move zfs roles to new storage subdir
Diffstat (limited to 'roles/storage/zfs/sanoid')
-rw-r--r--roles/storage/zfs/sanoid/defaults/main.yml28
-rw-r--r--roles/storage/zfs/sanoid/tasks/main.yml15
-rw-r--r--roles/storage/zfs/sanoid/templates/sanoid.conf.j223
3 files changed, 66 insertions, 0 deletions
diff --git a/roles/storage/zfs/sanoid/defaults/main.yml b/roles/storage/zfs/sanoid/defaults/main.yml
new file mode 100644
index 00000000..f48e9fd2
--- /dev/null
+++ b/roles/storage/zfs/sanoid/defaults/main.yml
@@ -0,0 +1,28 @@
+---
+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
+
+zfs_sanoid_templates_extra: {}
diff --git a/roles/storage/zfs/sanoid/tasks/main.yml b/roles/storage/zfs/sanoid/tasks/main.yml
new file mode 100644
index 00000000..e35190e9
--- /dev/null
+++ b/roles/storage/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/storage/zfs/sanoid/templates/sanoid.conf.j2 b/roles/storage/zfs/sanoid/templates/sanoid.conf.j2
new file mode 100644
index 00000000..82eb27a9
--- /dev/null
+++ b/roles/storage/zfs/sanoid/templates/sanoid.conf.j2
@@ -0,0 +1,23 @@
+###############################
+## modules
+###############################
+{% for name,options in zfs_sanoid_modules.items() %}
+
+[{{ name }}]
+{% for option,value in options.items() %}
+ {{ option }} = {{ value }}
+{% endfor %}
+{% endfor %}
+
+
+###############################
+## templates
+###############################
+{% set templates = zfs_sanoid_templates | combine(zfs_sanoid_templates_extra) %}
+{% for name,options in templates.items() %}
+
+[template_{{ name }}]
+{% for option,value in options.items() %}
+ {{ option }} = {{ value }}
+{% endfor %}
+{% endfor %}