This repository has been archived on 2024-02-16. You can view files and clone it, but cannot push or open issues or pull requests.
sysconfig/roles/cron/tasks/trim.yml

26 lines
718 B
YAML

---
# NOTE: dmcrypt discourages using `discard` mount option (as in BTRFS on LUKS),
# so running trim manually in a cron job
- name: cron | Create fstrim weekly job
copy:
src: fstrim
dest: /etc/periodic/weekly/fstrim
owner: root
group: root
mode: '755'
- name: cron | Create ZFS pool trim weekly job
copy:
content: |
#!/bin/sh
if /usr/sbin/zpool status {{ item }} | grep -qF "trimming"; then
exec /usr/sbin/zpool wait -t trim {{ item }}
else
exec /usr/sbin/zpool trim -w {{ item }}
fi
dest: /etc/periodic/weekly/trim-zfs-{{ item }}
mode: '755'
owner: root
group: root
loop: '{{ ansible_zfs_pools | map(attribute="name") | list }}'