ff
All checks were successful
ansible-lint / gitleaks (pull_request) Successful in 2s
ansible-lint / Ansible Lint (pull_request) Successful in 23s

This commit is contained in:
Michael Grote 2024-12-30 18:53:14 +01:00
parent 5078e04043
commit 555a638bfd
5 changed files with 5 additions and 42 deletions

View file

@ -8,16 +8,18 @@
group: "{{ sanoid_user_group }}" group: "{{ sanoid_user_group }}"
mode: "0400" mode: "0400"
- name: Template sanoid_mail.service - name: Ensure systemd services are templated
become: true become: true
ansible.builtin.template: ansible.builtin.template:
src: "sanoid_mail.service.j2" src: "{{ item }}.j2"
dest: /etc/systemd/system/sanoid_mail.service dest: /etc/systemd/system/{{ item }}
owner: root owner: root
group: root group: root
mode: "0644" mode: "0644"
notify: notify:
- systemctl daemon-reload - systemctl daemon-reload
loop:
- sanoid_mail.service
- name: add overrides (sanoid_mail + TZ) - name: add overrides (sanoid_mail + TZ)
become: true become: true

View file

@ -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

View file

@ -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 %}

View file

@ -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

View file

@ -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 }}'