diff --git a/roles/mgrote_zfs_scrub/tasks/main.yml b/roles/mgrote_zfs_scrub/tasks/main.yml index bfe0fa72..659cfcca 100644 --- a/roles/mgrote_zfs_scrub/tasks/main.yml +++ b/roles/mgrote_zfs_scrub/tasks/main.yml @@ -1,15 +1,20 @@ --- -- name: template unit-template +- name: Ensure systemd services are templated become: true ansible.builtin.template: - src: zpool-scrub@.service.j2 - dest: /etc/systemd/system/zpool-scrub@.service + src: "{{ item }}.j2" + dest: /etc/systemd/system/{{ item }} owner: root group: root mode: "0644" - register: template_unit + notify: + - systemctl daemon-reload + - systemctl enable units + loop: + - zpool-scrub@.service + - zpool-scrub-mail.service -- name: template timer +- name: Ensure systemd timers are templated become: true ansible.builtin.template: src: zpool-scrub@.timer.j2 @@ -20,24 +25,6 @@ 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: true - ansible.builtin.systemd: - daemon_reload: true - when: - - template_unit.changed - - template_timer.changed - - name: systemctl enable units - timer become: true ansible.builtin.systemd: @@ -45,9 +32,6 @@ enabled: true masked: false loop: "{{ zfs_extra_zfs_pools }}" - when: - - template_unit.changed - - template_timer.changed - name: systemctl enable units - mail become: true @@ -65,9 +49,6 @@ state: restarted enabled: true loop: "{{ zfs_extra_zfs_pools }}" - when: - - template_unit.changed - - template_timer.changed - name: remove old cronjobs become: true