mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-26 21:45:20 +02:00
Optimized alarm and system handlers
This commit is contained in:
parent
42d6c1799b
commit
f4a380d802
@ -6,5 +6,7 @@
|
|||||||
|
|
||||||
- include_role:
|
- include_role:
|
||||||
name: sys-service
|
name: sys-service
|
||||||
|
vars:
|
||||||
|
# If the email notifier fails, trigger the Telegram notifier,
|
||||||
|
# passing the failing unit's name as the instance text.
|
||||||
|
system_service_tpl_on_failure: "{{ ('sys-ctl-alm-telegram@') | get_service_name(SOFTWARE_NAME, False) }}%n.service"
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
|
|
||||||
- include_role:
|
- include_role:
|
||||||
name: sys-service
|
name: sys-service
|
||||||
|
vars:
|
||||||
|
# If the Telegram notifier fails, trigger the Email notifier,
|
||||||
|
# passing the failing unit's name as the instance text.
|
||||||
|
system_service_tpl_on_failure: "{{ ('sys-ctl-alm-email@') | get_service_name(SOFTWARE_NAME, False) }}%n.service"
|
||||||
|
|
||||||
- name: install curl
|
- name: install curl
|
||||||
community.general.pacman:
|
community.general.pacman:
|
||||||
|
@ -15,4 +15,4 @@ fi
|
|||||||
/usr/bin/curl -s -X POST \
|
/usr/bin/curl -s -X POST \
|
||||||
"https://api.telegram.org/bot{{ telegram_bot_token }}/sendMessage" \
|
"https://api.telegram.org/bot{{ telegram_bot_token }}/sendMessage" \
|
||||||
-d chat_id="{{ telegram_chat_id }}" \
|
-d chat_id="{{ telegram_chat_id }}" \
|
||||||
--data-urlencode text="service ${friendly} on ${host} failed"
|
--data-urlencode text="service ${friendly//\//-} on ${host} failed"
|
||||||
|
0
roles/sys-daemon/tasks/none.yml
Normal file
0
roles/sys-daemon/tasks/none.yml
Normal file
@ -1,3 +1,3 @@
|
|||||||
SYS_SERVICE_ALL_ENABLED: "{{ not MODE_DEBUG }}"
|
SYS_SERVICE_ALL_ENABLED: "{{ MODE_DEBUG }}"
|
||||||
SYS_SERVICE_DEFAULT_STATE: "{{ 'restarted' if MODE_DEBUG else omit }}"
|
SYS_SERVICE_DEFAULT_STATE: "{{ 'restarted' if MODE_DEBUG else omit }}"
|
||||||
SYS_SERVICE_DEFAULT_RUNTIME: "86400s" # Maximum total runtime a service is allowed to run before being stopped
|
SYS_SERVICE_DEFAULT_RUNTIME: "86400s" # Maximum total runtime a service is allowed to run before being stopped
|
@ -42,3 +42,4 @@
|
|||||||
notify: refresh systemctl service
|
notify: refresh systemctl service
|
||||||
when: not system_service_uses_at
|
when: not system_service_uses_at
|
||||||
when: SYS_SERVICE_ALL_ENABLED | bool
|
when: SYS_SERVICE_ALL_ENABLED | bool
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
- name: "Reload sys-daemon handlers"
|
||||||
|
include_tasks: "{{ playbook_dir }}/tasks/utils/load_handlers.yml"
|
||||||
|
vars:
|
||||||
|
handler_role_name: "sys-daemon"
|
||||||
|
when: run_once_sys_service is defined
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- include_tasks: 01_core.yml
|
- include_tasks: 01_core.yml
|
||||||
- include_tasks: utils/run_once.yml
|
- include_tasks: utils/run_once.yml
|
||||||
@ -7,6 +13,6 @@
|
|||||||
block:
|
block:
|
||||||
- name: "Load base routine for '{{ system_service_id }}'"
|
- name: "Load base routine for '{{ system_service_id }}'"
|
||||||
include_tasks: 03_base.yml
|
include_tasks: 03_base.yml
|
||||||
- name: "Flush system handlers for '{{ system_service_id }}'"
|
- name: "Flush system service handlers for '{{ system_service_id }}'"
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
when: system_service_id is defined
|
when: system_service_id is defined
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description={{ SOFTWARE_NAME }} - Service for role '{{ system_service_id }}'
|
Description={{ SOFTWARE_NAME }} - Service for role '{{ system_service_id }}'
|
||||||
{{- system_service_tpl_on_failure | systemd_directive('OnFailure') }}
|
{{- system_service_tpl_on_failure | systemd_directive('OnFailure') }}
|
||||||
|
StartLimitIntervalSec=60
|
||||||
|
StartLimitBurst=3
|
||||||
|
OnFailureJobMode=replace-irreversibly
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type={{ system_service_tpl_type }}
|
Type={{ system_service_tpl_type }}
|
||||||
{%- for key, val in [
|
{% for key, val in [
|
||||||
('TimeoutStartSec', system_service_tpl_timeout_start_sec),
|
('TimeoutStartSec', system_service_tpl_timeout_start_sec),
|
||||||
('ExecStartPre', system_service_tpl_exec_start_pre),
|
('ExecStartPre', system_service_tpl_exec_start_pre),
|
||||||
('ExecStart', system_service_tpl_exec_start),
|
('ExecStart', system_service_tpl_exec_start),
|
||||||
('RuntimeMaxSec', system_service_tpl_runtime)
|
('RuntimeMaxSec', system_service_tpl_runtime)
|
||||||
] -%}
|
] %}
|
||||||
{{- val | systemd_directive(key) }}
|
{{ val | systemd_directive(key) }}
|
||||||
{%- endfor %}
|
{% endfor %}
|
Loading…
x
Reference in New Issue
Block a user