-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.sls
63 lines (54 loc) · 1.76 KB
/
init.sls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{% from "zfs/defaults.jinja" import settings with context %}
include:
- zfs.autoscrub
- zfs.autotrim
- zfs.autosnapshot
zfs-utils:
pkg:
- installed
{% if grains['os_family'] == "Arch" %}
{% from 'arch/lib.sls' import aur_install with context %}
{% load_yaml as pkgs %}
# zfs-undelete - an easy-to-use cli tool to recover files from zfs snapshots
- zfs-undelete
{% endload %}
{{ aur_install("audio-pipewire-aur", pkgs) }}
{% endif %}
/etc/modprobe.d/zfs.conf:
file:
{% if settings.arc_max_limit == true %}
- managed
- contents: |
options zfs zfs_arc_max={{ settings.arc_max_bytes }}
{% else %}
- absent
{% endif %}
/etc/zfs/zfs-list.cache:
file.directory:
- makedirs: True
{% for service in ["zfs-import-cache", "zfs-mount", "zfs.target", "zfs-zed.service"] %}
enable_{{ service }}:
cmd.run:
- name: systemctl enable {{ service }}
{% endfor %}
{% for pool in settings.autoscrub.pools %}
zpool-scrub@{{ pool }}.timer:
cmd.run:
- name: systemctl {{ 'enable' if settings.autoscrub.enabled == true else 'disable' }} --now zpool-scrub@{{ pool }}.timer
- require:
- file: [email protected]
{% endfor %}
{% for pool in settings.autotrim.pools %}
zpool-trim@{{ pool }}.timer:
cmd.run:
- name: systemctl {{ 'enable' if settings.autotrim.enabled == true else 'disable' }} --now zpool-trim@{{ pool }}.timer
- require:
- file: [email protected]
{% endfor %}
{% for label in ['frequent', 'hourly', 'daily', 'weekly', 'monthly'] %}
zfs-snapshot@{{ label }}.timer:
cmd.run:
- name: systemctl {{ 'enable' if (settings.autosnapshot.enabled == true and settings.autosnapshot[label] != 0) else 'disable' }} --now zfs-snapshot-{{ label }}.timer
- require:
- file: zfs-snapshot-{{ label }}.timer
{% endfor %}