Add systemd mails
This commit is contained in:
parent
a507f524c3
commit
6f87c559e0
23
machine.yml
23
machine.yml
@ -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
|
||||||
|
11
root/usr/local/bin/systemd-mail.j2
Normal file
11
root/usr/local/bin/systemd-mail.j2
Normal 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
|
Loading…
Reference in New Issue
Block a user