mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-22 12:41:05 +01:00
Implemented systemd-email.service for native-pull-remote-backups
This commit is contained in:
parent
54a91a808b
commit
1276415dd0
@ -24,6 +24,5 @@ ansible-playbook -i ~/your-inventories/inventorie/hosts site.yml
|
||||
docker stop $(docker ps -aq); docker rm $(docker ps -aq); docker volume rm $(docker volume ls -q);
|
||||
``
|
||||
|
||||
## todo
|
||||
- implement smtp
|
||||
- implement administrator mail
|
||||
## see
|
||||
- https://wiki.archlinux.org/index.php/Ansible
|
||||
|
@ -1,2 +1,3 @@
|
||||
dependencies:
|
||||
- native-git
|
||||
- native-systemd-email
|
||||
|
@ -4,3 +4,4 @@ Description=pull remote backups
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/bash /usr/local/bin/pull-remote-backups.sh
|
||||
OnFailure=systemd-email@%n.service
|
||||
|
6
roles/native-systemd-email/readme.md
Normal file
6
roles/native-systemd-email/readme.md
Normal file
@ -0,0 +1,6 @@
|
||||
# native-systemd-mail
|
||||
|
||||
# see
|
||||
- https://wiki.archlinux.org/index.php/Systemd/Timers#MAILTO
|
||||
- https://serverfault.com/questions/876233/how-to-send-an-email-if-a-systemd-service-is-restarted/876254
|
||||
- https://serverfault.com/questions/694818/get-notification-when-systemd-monitored-service-enters-failed-state
|
11
roles/native-systemd-email/tasks/main.yml
Normal file
11
roles/native-systemd-email/tasks/main.yml
Normal file
@ -0,0 +1,11 @@
|
||||
- name: install smtp-forwarder
|
||||
pacman: name=smtp-forwarder state=present
|
||||
|
||||
- name: configure msmtprc.conf.j2
|
||||
template: src=msmtprc.conf.j2 dest=/root/.msmtprc
|
||||
|
||||
- name: configure systemd-email.sh
|
||||
template: src=systemd-email.sh.j2 dest=/usr/local/bin/systemd-email.sh
|
||||
|
||||
- name: configure systemd-email.service
|
||||
template: src=systemd-email.service.j2 dest=/etc/systemd/system/systemd-email.service
|
15
roles/native-systemd-email/templates/msmtprc.conf.j2
Normal file
15
roles/native-systemd-email/templates/msmtprc.conf.j2
Normal file
@ -0,0 +1,15 @@
|
||||
# Set default values for all following accounts.
|
||||
defaults
|
||||
auth on
|
||||
tls on
|
||||
tls_trust_file /etc/ssl/certs/ca-certificates.crt
|
||||
logfile ~/.msmtp.log
|
||||
|
||||
account system_email
|
||||
host {{system_email_host}}
|
||||
port 587
|
||||
from {{system_email}}
|
||||
user {{system_email_username}}
|
||||
password {{system_email_password}}
|
||||
|
||||
account default : system_email
|
@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=status email for %i to user
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/systemd-email.sh %i
|
||||
User=nobody
|
||||
Group=systemd-journal
|
11
roles/native-systemd-email/templates/systemd-email.sh.j2
Normal file
11
roles/native-systemd-email/templates/systemd-email.sh.j2
Normal file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/sendmail -t <<ERRMAIL
|
||||
To: {{administrator_email}}
|
||||
From: systemd <{{system_email}}>
|
||||
Subject: $1
|
||||
Content-Transfer-Encoding: 8bit
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
|
||||
$(systemctl status --full "$1")
|
||||
ERRMAIL
|
Loading…
Reference in New Issue
Block a user