From 75a94c9ac30e66dcba47faab061e290e70d8d2bb Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 1 Apr 2022 18:23:01 +0200 Subject: [PATCH] mail --- roles/mgrote.zfs_sanoid/tasks/main.yml | 15 +++++++++++++++ .../templates/sanoid_mail.service.j2 | 8 ++++++++ 2 files changed, 23 insertions(+) create mode 100644 roles/mgrote.zfs_sanoid/templates/sanoid_mail.service.j2 diff --git a/roles/mgrote.zfs_sanoid/tasks/main.yml b/roles/mgrote.zfs_sanoid/tasks/main.yml index 43ab8e76..d6d95a85 100644 --- a/roles/mgrote.zfs_sanoid/tasks/main.yml +++ b/roles/mgrote.zfs_sanoid/tasks/main.yml @@ -14,3 +14,18 @@ owner: root group: root mode: 0644 + + + - name: Generate Sanoid Configuration + become: true + community.general.ini_file: + path: "/ets/systemd/system/{{ item }}" + section: Unit + state: present + exclusive: no + no_extra_spaces: no + option: OnFailure + value: sanoid_mail.service + loop: + - sanoid.service + - sanoid-prune.service diff --git a/roles/mgrote.zfs_sanoid/templates/sanoid_mail.service.j2 b/roles/mgrote.zfs_sanoid/templates/sanoid_mail.service.j2 new file mode 100644 index 00000000..fda6f620 --- /dev/null +++ b/roles/mgrote.zfs_sanoid/templates/sanoid_mail.service.j2 @@ -0,0 +1,8 @@ +{{ file_header | default () }} + +[Unit] +Description=Send a Mail in case of an error in sanoid.service. + +[Service] +Type=oneshot +ExecStart=/bin/bash -c '/bin/systemctl status sanoid.service | mail -s "[ERROR] sanoid - %H" {{ empfaenger_mail }}'