Pin the fstrim timer and the monthly ZFS trim and scrub per host in the common role to keep them out of the backup window
This commit is contained in:
Regular → Executable
+8
-1
@@ -1 +1,8 @@
|
|||||||
ipv6_stable_secret: 1111:2222:3333:4444:5555:6666:7777:8888
|
ipv6_stable_secret_seed: "@JW7rQ^P3*f^KRkX3744DZQJb3DfMgZJJMtGc!Jmy!ECBqb^QzAMYLHD8dLvf8m%2bRSRFhgY#SXzAgnxWTvHv#ti6b5PngR^k2gHbQW*%dJ9sdeKM$H77Gymh&xamNN"
|
||||||
|
|
||||||
|
# Times of the heavy disk jobs, for hosts on a shared HDD pool that keep them out of the backup window.
|
||||||
|
disk_maintenance:
|
||||||
|
# systemd OnCalendar for fstrim.timer; unset keeps the distribution schedule.
|
||||||
|
fstrim_on_calendar:
|
||||||
|
# Cron "minute hour" of the monthly ZFS trim and scrub from zfsutils-linux; unset keeps 00:24.
|
||||||
|
zfs_cron_time:
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
- name: Pin the fstrim timer
|
||||||
|
when: disk_maintenance.fstrim_on_calendar | default(none) is not none
|
||||||
|
block:
|
||||||
|
- name: Create the fstrim timer drop-in directory
|
||||||
|
file:
|
||||||
|
path: /etc/systemd/system/fstrim.timer.d
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Set the fstrim timer schedule
|
||||||
|
copy:
|
||||||
|
dest: /etc/systemd/system/fstrim.timer.d/schedule.conf
|
||||||
|
content: |
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=
|
||||||
|
OnCalendar={{ disk_maintenance.fstrim_on_calendar }}
|
||||||
|
RandomizedDelaySec=0
|
||||||
|
# A catch-up run after a boot or a timezone change would land at any time.
|
||||||
|
Persistent=false
|
||||||
|
register: fstrim_timer
|
||||||
|
|
||||||
|
- name: Restart the fstrim timer
|
||||||
|
when: fstrim_timer.changed
|
||||||
|
systemd:
|
||||||
|
name: fstrim.timer
|
||||||
|
daemon_reload: yes
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: Schedule the monthly ZFS trim and scrub
|
||||||
|
when: disk_maintenance.zfs_cron_time | default(none) is not none
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/cron.d/zfsutils-linux
|
||||||
|
regexp: '^\S+ \S+ (\S+ \* \* root .*/usr/lib/zfs-linux/{{ item }};.*)$'
|
||||||
|
line: '{{ disk_maintenance.zfs_cron_time }} \1'
|
||||||
|
backrefs: yes
|
||||||
|
loop: [trim, scrub]
|
||||||
Regular → Executable
+2
@@ -9,3 +9,5 @@
|
|||||||
- import_tasks: ./aliases.yml
|
- import_tasks: ./aliases.yml
|
||||||
|
|
||||||
- import_tasks: ./networking.yml
|
- import_tasks: ./networking.yml
|
||||||
|
|
||||||
|
- import_tasks: ./disk_maintenance.yml
|
||||||
|
|||||||
Reference in New Issue
Block a user