2023-10-25 22:26:17 +02:00
|
|
|
---
|
2024-12-30 20:06:25 +01:00
|
|
|
- name: Ensure systemd services are templated
|
2023-10-25 22:26:17 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
2024-12-30 20:06:25 +01:00
|
|
|
src: "{{ item }}.j2"
|
|
|
|
dest: /etc/systemd/system/{{ item }}
|
2023-10-25 22:26:17 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
2024-12-30 20:06:25 +01:00
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
|
|
|
- systemctl enable units
|
|
|
|
loop:
|
|
|
|
- zpool-scrub@.service
|
|
|
|
- zpool-scrub-mail.service
|
2023-10-25 22:26:17 +02:00
|
|
|
|
2024-12-30 20:06:25 +01:00
|
|
|
- name: Ensure systemd timers are templated
|
2023-10-25 22:26:17 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: zpool-scrub@.timer.j2
|
|
|
|
dest: "/etc/systemd/system/zpool-scrub@{{ item.name }}.timer"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
|
|
|
loop: "{{ zfs_extra_zfs_pools }}"
|
|
|
|
|
|
|
|
- name: systemctl enable units - timer
|
|
|
|
become: true
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "zpool-scrub@{{ item.name }}.timer"
|
|
|
|
enabled: true
|
|
|
|
masked: false
|
|
|
|
loop: "{{ zfs_extra_zfs_pools }}"
|
|
|
|
|
|
|
|
- name: systemctl enable units - mail
|
|
|
|
become: true
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "zpool-scrub-mail.service"
|
|
|
|
enabled: true
|
|
|
|
masked: false
|
|
|
|
|
|
|
|
- name: systemctl start units
|
|
|
|
become: true
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "zpool-scrub@{{ item.name }}.timer"
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|
|
|
|
loop: "{{ zfs_extra_zfs_pools }}"
|
|
|
|
|
|
|
|
- name: remove old cronjobs
|
|
|
|
become: true
|
|
|
|
ansible.builtin.cron:
|
|
|
|
name: zfs-scrub - "{{ item.name }}"
|
|
|
|
state: absent
|
|
|
|
with_items: "{{ zfs_extra_zfs_pools }}"
|
|
|
|
|
|
|
|
- name: remove proxmox system scrub job #https://forum.proxmox.com/threads/script-sequential-zfs-scrub-for-cron.25124/
|
|
|
|
become: true
|
|
|
|
ansible.builtin.lineinfile:
|
|
|
|
path: /etc/cron.d/zfsutils-linux
|
|
|
|
state: absent
|
|
|
|
line: '24 0 8-14 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/scrub ]; then /usr/lib/zfs-linux/scrub; fi'
|