Add systemd mails

This commit is contained in:
Wojciech Kozlowski 2022-08-28 04:01:22 +02:00
parent a507f524c3
commit 6f87c559e0
2 changed files with 34 additions and 0 deletions

View File

@ -91,3 +91,26 @@
mail_postfix_install is changed or mail_postfix_install is changed or
mail_postfix_cfg is changed or mail_postfix_cfg is changed or
mail_postfix_credentials is changed mail_postfix_credentials is changed
# ----------------------------------------------------------------------------------------------
# SystemD mails.
# ----------------------------------------------------------------------------------------------
- name: SystemD mail script
template:
src: ./root/usr/local/bin/systemd-mail.j2
dest: /usr/local/bin/systemd-mail
mode: 0755
- name: SystemD mail service
copy:
src: ./root/etc/systemd/system/status-mail@.service
dest: /etc/systemd/system/status-mail@.service
mode: 0644
register: systemd_status_mail_service_file
- name: SystemD daemon reload
systemd:
daemon_reload: true
when:
systemd_status_mail_service_file is changed

View File

@ -0,0 +1,11 @@
#!/bin/sh
/usr/sbin/sendmail -t <<SYSTEMDMAIL
To: root
From: systemd <{{ hostname }}>
Subject: $1
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=UTF-8
$(systemctl status --full "$1")
SYSTEMDMAIL