mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 23:08:06 +02:00
Finished backup-to-swappable draft
This commit is contained in:
6
roles/independent_systemd-email/README.md
Normal file
6
roles/independent_systemd-email/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# server_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
|
4
roles/independent_systemd-email/handlers/main.yml
Normal file
4
roles/independent_systemd-email/handlers/main.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
- name: "restart systemd-email service"
|
||||
systemd:
|
||||
name: systemd-email.service
|
||||
daemon_reload: yes
|
18
roles/independent_systemd-email/tasks/main.yml
Normal file
18
roles/independent_systemd-email/tasks/main.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
- name: install smtp-forwarder
|
||||
pacman: name=smtp-forwarder state=present
|
||||
|
||||
- name: configure msmtprc.conf.j2
|
||||
template: src=msmtprc.conf.j2 dest=/root/.msmtprc
|
||||
|
||||
- name: "create {{systemd_email_folder}}"
|
||||
file:
|
||||
path: "{{systemd_email_folder}}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: configure systemd-email.sh
|
||||
template: src=systemd-email.sh.j2 dest={{systemd_email_folder}}systemd-email.sh
|
||||
|
||||
- name: configure systemd-email.service
|
||||
template: src=systemd-email@.service.j2 dest=/etc/systemd/system/systemd-email@.service
|
||||
notify: restart systemd-email service
|
15
roles/independent_systemd-email/templates/msmtprc.conf.j2
Normal file
15
roles/independent_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 {{system_email_port}}
|
||||
from {{system_email}}
|
||||
user {{system_email_username}}
|
||||
password {{system_email_password}}
|
||||
|
||||
account default : system_email
|
@@ -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
|
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=status email for %i to user
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash {{systemd_email_folder}}systemd-email.sh %i
|
||||
User=root
|
||||
Group=systemd-journal
|
1
roles/independent_systemd-email/vars/main.yml
Normal file
1
roles/independent_systemd-email/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
systemd_email_folder: "{{path_administrator_scripts}}systemd_email/"
|
Reference in New Issue
Block a user