papanito.systemd_notifiers

Ansible role to setup a systemd notification service for failing systemd services

Posted July 19, 2022 by Adrian Wyssmann

Source

https://github.com/papanito/ansible-role-systemd_notifiers

Role Summary

Ansible Role Ansible Quality Score Ansible Role GitHub issues GitHub pull requests

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 as sn_username - it seems otherwise desktop notifications don’t come trough
  • I used different scripts:
  • sn_googlechat_url: as url may contain special charaters like % one cannot use this pass it in the .service file but has to use an EnvironmentFile