Add email notifications for failed certbot runs
Based on https://wiki.archlinux.org/index.php/Systemd/Timers#MAILTO This can easily be used by other services, with one line added to the [Unit] section of a service: OnFailure=status-email-ops@%n.service Refs #3
This commit is contained in:
9
site-cookbooks/kosmos-base/files/default/certbot.service
Normal file
9
site-cookbooks/kosmos-base/files/default/certbot.service
Normal file
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Certbot
|
||||
Documentation=file:///usr/share/doc/python-certbot-doc/html/index.html
|
||||
Documentation=https://letsencrypt.readthedocs.io/en/latest/
|
||||
OnFailure=status-email-ops@%n.service
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/certbot -q renew
|
||||
PrivateTmp=true
|
||||
11
site-cookbooks/kosmos-base/files/default/systemd-email
Normal file
11
site-cookbooks/kosmos-base/files/default/systemd-email
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/sbin/sendmail -t <<ERRMAIL
|
||||
To: $1
|
||||
From: systemd <root@$HOSTNAME>
|
||||
Subject: $2
|
||||
Content-Transfer-Encoding: 8bit
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
|
||||
$(systemctl status --full "$2")
|
||||
ERRMAIL
|
||||
Reference in New Issue
Block a user