ansible-edda/playbooks/roles/system/zfs/tasks/include/fstrim.yml

32 lines
971 B
YAML

---
# Run fstrim daily on ZFS. It's a no-op on ZFS filesystems, but it will run on zvols mounted via
# fstab. Untrimmed zvol blocks occupy space in th ZFS pool. Therefore, this helps keep zvol space
# requirements down if they are busy.
- name: "fstrim : configure a daily fstrim timer"
ansible.builtin.copy:
src: "./fstrim/fstrim.timer"
dest: "/etc/systemd/system/fstrim.timer"
mode: 0644
register: system_zfs_fstrim_timer_file
- name: "fstrim : systemd daemon reload"
ansible.builtin.systemd:
daemon_reload: true
when:
system_zfs_fstrim_timer_file.changed
# Disabling is necessary to make sure systemd uses the new timer file.
- name: "fstrim : disable fstrim.timer"
ansible.builtin.systemd:
name: "fstrim.timer"
enabled: false
state: "stopped"
when:
system_zfs_fstrim_timer_file.changed
- name: "fstrim : enable fstrim.timer"
ansible.builtin.systemd:
name: "fstrim.timer"
enabled: true
state: "started"