2021-02-13 16:18:29 +01:00
|
|
|
---
|
2022-03-19 13:28:41 +01:00
|
|
|
- name: template unit-template
|
2021-02-13 16:18:29 +01:00
|
|
|
become: true
|
2022-03-19 13:28:41 +01:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: zpool-scrub@.service.j2
|
|
|
|
dest: /etc/systemd/system/zpool-scrub@.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
register: template_unit
|
|
|
|
|
|
|
|
- name: template timer
|
|
|
|
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 }}"
|
|
|
|
register: template_timer
|
|
|
|
|
|
|
|
- name: template mail.service
|
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: zpool-scrub-mail.service.j2
|
|
|
|
dest: "/etc/systemd/system/zpool-scrub-mail.service"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
register: template_mail
|
|
|
|
|
|
|
|
- name: systemctl daemon-reload
|
|
|
|
become: yes
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
when:
|
|
|
|
- template_unit.changed
|
|
|
|
- template_timer.changed
|
|
|
|
|
|
|
|
- name: systemctl enable units - timer
|
|
|
|
become: yes
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "zpool-scrub@{{ item.name }}.timer"
|
|
|
|
enabled: yes
|
|
|
|
masked: no
|
|
|
|
loop: "{{ zfs_extra_zfs_pools }}"
|
|
|
|
when:
|
|
|
|
- template_unit.changed
|
|
|
|
- template_timer.changed
|
2021-02-13 16:18:29 +01:00
|
|
|
|
2022-03-19 13:28:41 +01:00
|
|
|
- name: systemctl enable units - mail
|
|
|
|
become: yes
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "zpool-scrub-mail.service"
|
|
|
|
enabled: yes
|
|
|
|
masked: no
|
|
|
|
when:
|
|
|
|
- template_mail
|
|
|
|
|
|
|
|
- name: systemctl start units
|
|
|
|
become: yes
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: "zpool-scrub@{{ item.name }}.timer"
|
|
|
|
state: restarted
|
|
|
|
enabled: yes
|
|
|
|
loop: "{{ zfs_extra_zfs_pools }}"
|
|
|
|
when:
|
|
|
|
- template_unit.changed
|
|
|
|
- template_timer.changed
|
|
|
|
|
|
|
|
- name: remove old cronjobs
|
2021-02-13 16:18:29 +01:00
|
|
|
become: yes
|
|
|
|
ansible.builtin.cron:
|
|
|
|
name: zfs-scrub - "{{ item.name }}"
|
2022-03-19 13:28:41 +01:00
|
|
|
state: absent
|
2021-02-13 16:18:29 +01:00
|
|
|
with_items: "{{ zfs_extra_zfs_pools }}"
|
2022-03-19 13:28:41 +01:00
|
|
|
|
|
|
|
- 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
|
2023-04-02 12:03:47 +02:00
|
|
|
line: '24 0 8-14 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/scrub ]; then /usr/lib/zfs-linux/scrub; fi'
|