common: disk_maintenance.fstrim_mountpoints limits fstrim.service to the listed mountpoints
This commit is contained in:
@@ -8,6 +8,8 @@ ipv6_accept_ra_interfaces: []
|
|||||||
disk_maintenance:
|
disk_maintenance:
|
||||||
# systemd OnCalendar for fstrim.timer; unset keeps the distribution schedule.
|
# systemd OnCalendar for fstrim.timer; unset keeps the distribution schedule.
|
||||||
fstrim_on_calendar:
|
fstrim_on_calendar:
|
||||||
|
# Mountpoints fstrim.service trims; unset trims every fstab filesystem.
|
||||||
|
fstrim_mountpoints:
|
||||||
# Cron "minute hour" of the monthly ZFS trim and scrub from zfsutils-linux; unset keeps 00:24.
|
# Cron "minute hour" of the monthly ZFS trim and scrub from zfsutils-linux; unset keeps 00:24.
|
||||||
zfs_cron_time:
|
zfs_cron_time:
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,36 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: Create the fstrim service drop-in directory
|
||||||
|
when: disk_maintenance.fstrim_mountpoints | default(none) is not none
|
||||||
|
file:
|
||||||
|
path: /etc/systemd/system/fstrim.service.d
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Set the fstrim mountpoints
|
||||||
|
when: disk_maintenance.fstrim_mountpoints | default(none) is not none
|
||||||
|
copy:
|
||||||
|
dest: /etc/systemd/system/fstrim.service.d/mountpoints.conf
|
||||||
|
content: |
|
||||||
|
[Service]
|
||||||
|
ExecStart=
|
||||||
|
{% for m in disk_maintenance.fstrim_mountpoints %}
|
||||||
|
ExecStart=/sbin/fstrim --verbose --quiet-unsupported {{ m }}
|
||||||
|
{% endfor %}
|
||||||
|
register: fstrim_mountpoints
|
||||||
|
|
||||||
|
- name: Trim every fstab filesystem
|
||||||
|
when: disk_maintenance.fstrim_mountpoints | default(none) is none
|
||||||
|
file:
|
||||||
|
path: /etc/systemd/system/fstrim.service.d/mountpoints.conf
|
||||||
|
state: absent
|
||||||
|
register: fstrim_mountpoints_removed
|
||||||
|
|
||||||
|
- name: Reload systemd for the fstrim mountpoints
|
||||||
|
when: fstrim_mountpoints.changed or fstrim_mountpoints_removed.changed
|
||||||
|
systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
|
||||||
- name: Schedule the monthly ZFS trim and scrub
|
- name: Schedule the monthly ZFS trim and scrub
|
||||||
when: disk_maintenance.zfs_cron_time | default(none) is not none
|
when: disk_maintenance.zfs_cron_time | default(none) is not none
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
|||||||
Reference in New Issue
Block a user