mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-31 07:48:04 +02:00
Refactor alarm compose service and systemctl templates
- Fixed bug where not both alarm services (email + telegram) were triggered. - Removed direct OnFailure references for email and telegram, now handled by unified compose service. - Introduced 01_core.yml in sys-ctl-alm-compose to structure role execution (subservices → core service → test run). - Added configurable variables SYSTEMCTL_ALARM_COMPOSER_SUBSERVICES and SYSTEMCTL_ALARM_COMPOSER_DUMMY_MESSAGE. - Replaced dedicated @.service template with generic systemctl template using systemctl_tpl_* variables for flexibility. - Updated script.sh.j2 to collect exit codes and print clear errors. - Fixed typos and streamlined vars in sys-systemctl. See conversation: https://chatgpt.com/share/68a46172-7c3c-800f-a69c-0cb9edd6839f
This commit is contained in:
11
roles/sys-ctl-alm-compose/templates/script.sh.j2
Normal file
11
roles/sys-ctl-alm-compose/templates/script.sh.j2
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
err=0
|
||||
set -u
|
||||
{% for alarm_service in SYSTEMCTL_ALARM_COMPOSER_SUBSERVICES %}
|
||||
{% set alarm_service_full_name = alarm_service | get_service_name(SOFTWARE_NAME, '"$1".service') %}
|
||||
if ! /usr/bin/systemctl start {{ alarm_service_full_name }}; then
|
||||
echo "ERROR: Failed to start {{ alarm_service_full_name }}" >&2
|
||||
err=1
|
||||
fi
|
||||
{% endfor %}
|
||||
exit $err
|
@@ -1,10 +0,0 @@
|
||||
[Unit]
|
||||
Description={{ SOFTWARE_NAME }} - Alarm Notifier for %i
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
{% for alarm_service in [ SYS_SERVICE_ON_FAILURE_EMAIL, SYS_SERVICE_ON_FAILURE_TELEGRAM ] %}
|
||||
ExecStart=/usr/bin/systemctl start {{ alarm_service }}
|
||||
{% endfor %}
|
||||
User=root
|
||||
Group=systemd-journal
|
Reference in New Issue
Block a user