Add status mail for user servies as well
This commit is contained in:
parent
df86c2b6a8
commit
4b9dc63253
@ -7,6 +7,7 @@
|
|||||||
- import_tasks: tasks/hosts/firewall.yml
|
- import_tasks: tasks/hosts/firewall.yml
|
||||||
- import_tasks: tasks/hosts/ntp.yml
|
- import_tasks: tasks/hosts/ntp.yml
|
||||||
- import_tasks: tasks/hosts/mail.yml
|
- import_tasks: tasks/hosts/mail.yml
|
||||||
|
- import_tasks: tasks/hosts/systemd-mail.yml
|
||||||
- import_tasks: tasks/hosts/unattended-upgrades.yml
|
- import_tasks: tasks/hosts/unattended-upgrades.yml
|
||||||
- import_tasks: tasks/hosts/fail2ban.yml
|
- import_tasks: tasks/hosts/fail2ban.yml
|
||||||
- import_tasks: tasks/hosts/fstrim.yml
|
- import_tasks: tasks/hosts/fstrim.yml
|
||||||
@ -20,7 +21,6 @@
|
|||||||
hosts: yggdrasil
|
hosts: yggdrasil
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- import_tasks: tasks/hosts/systemd-mail.yml
|
|
||||||
- import_tasks: tasks/hosts/zfs-conf.yml
|
- import_tasks: tasks/hosts/zfs-conf.yml
|
||||||
- import_tasks: tasks/hosts/zfs-scrub.yml
|
- import_tasks: tasks/hosts/zfs-scrub.yml
|
||||||
- import_tasks: tasks/hosts/zfs-trim.yml
|
- import_tasks: tasks/hosts/zfs-trim.yml
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Connect %i to root bridge
|
Description=Connect %i to root bridge
|
||||||
After=network.target
|
After=network.target
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Status email for %i
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/local/bin/systemd-mail-systemctl-status %i
|
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/usr/sbin/sendmail -t <<SYSTEMDMAIL
|
||||||
|
To: root
|
||||||
|
From: $(whoami).systemd <systemd>
|
||||||
|
Subject: systemctl --user status $1 on {{ ansible_hostname }}
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
|
||||||
|
$(systemctl --user status --full "$1")
|
||||||
|
SYSTEMDMAIL
|
@ -1,6 +1,7 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Podman container-rproxy-certbot.service
|
Description=Podman container-rproxy-certbot.service
|
||||||
Documentation=man:podman-generate-systemd(1)
|
Documentation=man:podman-generate-systemd(1)
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
@ -5,6 +5,7 @@ Wants=network.target
|
|||||||
After=network-online.target
|
After=network-online.target
|
||||||
BindsTo=pod-rproxy.service
|
BindsTo=pod-rproxy.service
|
||||||
After=pod-rproxy.service
|
After=pod-rproxy.service
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
@ -5,6 +5,7 @@ Wants=network.target
|
|||||||
After=network-online.target
|
After=network-online.target
|
||||||
Requires=container-rproxy-nginx.service
|
Requires=container-rproxy-nginx.service
|
||||||
Before=container-rproxy-nginx.service
|
Before=container-rproxy-nginx.service
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
@ -5,6 +5,7 @@ Wants=network.target
|
|||||||
After=network-online.target
|
After=network-online.target
|
||||||
BindsTo=pod-www.service
|
BindsTo=pod-www.service
|
||||||
After=pod-www.service
|
After=pod-www.service
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
@ -5,6 +5,7 @@ Wants=network.target
|
|||||||
After=network-online.target
|
After=network-online.target
|
||||||
Requires=container-www-nginx.service
|
Requires=container-www-nginx.service
|
||||||
Before=container-www-nginx.service
|
Before=container-www-nginx.service
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Backup volume snapshots using restic
|
Description=Backup volume snapshots using restic
|
||||||
Documentation=man:restic(8)
|
Documentation=man:restic(8)
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
@ -3,6 +3,7 @@ Description=Replicate volume data snapshots
|
|||||||
Documentation=man:syncoid(8)
|
Documentation=man:syncoid(8)
|
||||||
After=sanoid.service
|
After=sanoid.service
|
||||||
Before=sanoid-prune.service
|
Before=sanoid-prune.service
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
@ -5,6 +5,7 @@ Wants=network.target
|
|||||||
After=network-online.target
|
After=network-online.target
|
||||||
BindsTo=pod-database.service
|
BindsTo=pod-database.service
|
||||||
After=pod-database.service
|
After=pod-database.service
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
@ -5,6 +5,7 @@ Wants=network.target
|
|||||||
After=network-online.target
|
After=network-online.target
|
||||||
Requires=container-database-postgres.service
|
Requires=container-database-postgres.service
|
||||||
Before=container-database-postgres.service
|
Before=container-database-postgres.service
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
@ -5,6 +5,7 @@ Wants=network.target
|
|||||||
After=network-online.target
|
After=network-online.target
|
||||||
BindsTo=pod-lrproxy.service
|
BindsTo=pod-lrproxy.service
|
||||||
After=pod-lrproxy.service
|
After=pod-lrproxy.service
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
@ -5,6 +5,7 @@ Wants=network.target
|
|||||||
After=network-online.target
|
After=network-online.target
|
||||||
Requires=container-lrproxy-nginx.service
|
Requires=container-lrproxy-nginx.service
|
||||||
Before=container-lrproxy-nginx.service
|
Before=container-lrproxy-nginx.service
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment=PODMAN_SYSTEMD_UNIT=%n
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Podman rsync-certificates.service
|
Description=Podman rsync-certificates.service
|
||||||
Documentation=man:rsync(1)
|
Documentation=man:rsync(1)
|
||||||
|
OnFailure=status-mail@%n.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
@ -1,18 +1,32 @@
|
|||||||
- name: SystemD mail script
|
- name: SystemD mail root script
|
||||||
template:
|
template:
|
||||||
src: ./filesystem/{{ ansible_hostname }}/usr/local/sbin/systemd-mail-systemctl-status.j2
|
src: ./filesystem/common/usr/local/sbin/systemd-mail-systemctl-status.j2
|
||||||
dest: /usr/local/sbin/systemd-mail-systemctl-status
|
dest: /usr/local/sbin/systemd-mail-systemctl-status
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: SystemD mail service
|
- name: SystemD mail user script
|
||||||
|
template:
|
||||||
|
src: ./filesystem/common/usr/local/bin/systemd-mail-systemctl-status.j2
|
||||||
|
dest: /usr/local/bin/systemd-mail-systemctl-status
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: SystemD mail root service
|
||||||
copy:
|
copy:
|
||||||
src: ./filesystem/{{ ansible_hostname }}/etc/systemd/system/status-mail@.service
|
src: ./filesystem/common/etc/systemd/system/status-mail@.service
|
||||||
dest: /etc/systemd/system/status-mail@.service
|
dest: /etc/systemd/system/status-mail@.service
|
||||||
mode: 0644
|
mode: 0644
|
||||||
register: systemd_status_mail_service_file
|
register: systemd_system_status_mail_service_file
|
||||||
|
|
||||||
|
- name: SystemD mail user service
|
||||||
|
copy:
|
||||||
|
src: ./filesystem/common/etc/systemd/user/status-mail@.service
|
||||||
|
dest: /etc/systemd/user/status-mail@.service
|
||||||
|
mode: 0644
|
||||||
|
register: systemd_user_status_mail_service_file
|
||||||
|
|
||||||
- name: SystemD daemon reload
|
- name: SystemD daemon reload
|
||||||
systemd:
|
systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
when:
|
when:
|
||||||
systemd_status_mail_service_file is changed
|
systemd_system_status_mail_service_file is changed or
|
||||||
|
systemd_user_status_mail_service_file is changed
|
||||||
|
Loading…
Reference in New Issue
Block a user