diff --git a/roles/mgrote_zfs_sanoid/tasks/snaps.yml b/roles/mgrote_zfs_sanoid/tasks/snaps.yml index 47b3b049..e8743a46 100644 --- a/roles/mgrote_zfs_sanoid/tasks/snaps.yml +++ b/roles/mgrote_zfs_sanoid/tasks/snaps.yml @@ -8,16 +8,18 @@ group: "{{ sanoid_user_group }}" mode: "0400" -- name: Template sanoid_mail.service +- name: Ensure systemd services are templated become: true ansible.builtin.template: - src: "sanoid_mail.service.j2" - dest: /etc/systemd/system/sanoid_mail.service + src: "{{ item }}.j2" + dest: /etc/systemd/system/{{ item }} owner: root group: root mode: "0644" notify: - systemctl daemon-reload + loop: + - sanoid_mail.service - name: add overrides (sanoid_mail + TZ) become: true diff --git a/roles/mgrote_zfs_sanoid/templates/syncoid.service.j2 b/roles/mgrote_zfs_sanoid/templates/syncoid.service.j2 deleted file mode 100644 index af61c7f5..00000000 --- a/roles/mgrote_zfs_sanoid/templates/syncoid.service.j2 +++ /dev/null @@ -1,10 +0,0 @@ -{{ file_header | default () }} - -[Unit] -Description=Send zfs snapshots with sanoid/syncoid. -OnFailure=syncoid_mail.service -OnSuccess=syncoid_mail.service - -[Service] -Type=simple -ExecStart=/usr/bin/syncoid.sh diff --git a/roles/mgrote_zfs_sanoid/templates/syncoid.sh.j2 b/roles/mgrote_zfs_sanoid/templates/syncoid.sh.j2 deleted file mode 100644 index 68b2f752..00000000 --- a/roles/mgrote_zfs_sanoid/templates/syncoid.sh.j2 +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -{{ file_header | default () }} - -# check if dest-dataset is mounted (sed: entferne 1. Zeile; awk: zeige nur yes/no; grep: RC1 when != yes) -{% for item in sanoid_syncoid_datasets_sync %} -# check if target dataset is mounted -/usr/sbin/zfs get mounted -H {{ item.destination_mount_check }} 2>&1 > /dev/null || echo "Pool not mounted!" -# check if source host is reachable -ping -c1 -W1 {{ item.source_host }} > /dev/null || {{ item.source_host }} not reachable! -# syncoid -export HOME=/root ; /usr/bin/syncoid --compress=zstd-fast --sshoption=StrictHostKeyChecking=no --delete-target-snapshots --use-hold --preserve-recordsize --sshkey "/etc/sanoid/.ssh/id_sanoid" --source-bwlimit {{ sanoid_syncoid_bwlimit }} {{ sanoid_user }}@{{ item.source_host }}:{{ item.source_dataset }} {{ item.destination_dataset }} -{% endfor %} diff --git a/roles/mgrote_zfs_sanoid/templates/syncoid.timer.j2 b/roles/mgrote_zfs_sanoid/templates/syncoid.timer.j2 deleted file mode 100644 index 16438ec7..00000000 --- a/roles/mgrote_zfs_sanoid/templates/syncoid.timer.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{{ file_header | default () }} -[Unit] -Description=Timer for syncoid. - -[Timer] -OnCalendar={{ sanoid_syncoid_timer }} - -[Install] -WantedBy=timers.target multi-user.target zfs.target diff --git a/roles/mgrote_zfs_sanoid/templates/syncoid_mail.service.j2 b/roles/mgrote_zfs_sanoid/templates/syncoid_mail.service.j2 deleted file mode 100644 index caa59b24..00000000 --- a/roles/mgrote_zfs_sanoid/templates/syncoid_mail.service.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{{ file_header | default () }} - -[Unit] -Description=Send a Mail for sanoid service after error or success sanoid.service. - -[Service] -Type=oneshot -ExecStart=/bin/bash -c '/usr/bin/journalctl -u syncoid.service -n 30 | mail -aFROM:syncoid@mgrote.net -s "syncoid - %H" {{ my_mail }}'