papanito.systemd_notifiers
Ansible role to setup a systemd notification service for failing systemd services
Posted May 12, 2022 by Adrian Wyssmann
Source
https://github.com/papanito/ansible-role-systemd_notifiers
Role Summary
When systemd services fail you usually don’t really notice it unless it’s a critical service. However there may be situations where it would be nice that you are mare aware of failing services. This role will setup systemd jobs of type oneshot
which you can the use in your critical services, by using them in the [OnFailure
][OnFailure]:
A space-separated list of one or more units that are activated when this unit enters the “failed” state.
See also [Notifications for failing Systemd services]({<ref “notifications-for-failing-systemd-services”>}}) for the idea behind this role.
Background
As written in my last post Notifications for failing Systemd services the idea is to be able to get notified in case of critical systemd services fail. Some things you may consider
- for desktop notifications the service user
sn_systemd_user
has to be the same assn_username
- it seems otherwise desktop notifications don’t come trough - I used different scripts:
- notify-chat.sh - for googlechat notifications
- notify-desktop.sh - for desktop notifications
- notify-mail.sh - for mail notifications
sn_googlechat_url
: as url may contain special charaters like%
one cannot use this pass it in the.service
file but has to use anEnvironmentFile