Refactor systemctl services and timers

- Unified service templates into generic systemctl templates
- Introduced reusable filter plugins for script path handling
- Updated path variables and service/timer definitions
- Migrated roles (backup, cleanup, repair, etc.) to use systemctl role
- Added sys-daemon role for core systemd cleanup
- Simplified timer handling via sys-timer role

Note: This is a large refactor and some errors may still exist. Further testing and adjustments will be needed.
This commit is contained in:
2025-08-18 21:22:16 +02:00
parent 3a839cfe37
commit 2569abc0be
219 changed files with 618 additions and 1104 deletions

View File

@@ -1,5 +0,0 @@
- name: "Reload sys-ctl-cln-faild-bkps service"
systemd:
name: sys-ctl-cln-faild-bkps{{ SYS_SERVICE_SUFFIX }}
enabled: yes
daemon_reload: yes

View File

@@ -5,36 +5,26 @@
- sys-ctl-alm-compose
- sys-lock
- sys-svc-directory-validator
- sys-rst-daemon
- sys-daemon
- name: "pkgmgr install"
include_role:
name: pkgmgr-install
vars:
package_name: "{{ cln_failed_docker_backups_pkg }}"
package_name: "{{ CLN_FAILED_DOCKER_BACKUPS_PKG }}"
- name: "Retrieve {{ cln_failed_docker_backups_pkg }} path from pkgmgr"
command: "pkgmgr path {{ cln_failed_docker_backups_pkg }}"
- name: "Retrieve {{ CLN_FAILED_DOCKER_BACKUPS_PKG }} path from pkgmgr"
command: "pkgmgr path {{ CLN_FAILED_DOCKER_BACKUPS_PKG }}"
register: pkgmgr_output
changed_when: false
- name: Set fact for backup_docker_to_local_cleanup_script
- name: Set fact for BACKUP_CLEANUP_SCRIPT
set_fact:
backup_docker_to_local_cleanup_script: "{{ pkgmgr_output.stdout.rstrip('/') ~ '/cleanup-all.sh' }}"
BACKUP_CLEANUP_SCRIPT: "{{ pkgmgr_output.stdout.rstrip('/') ~ '/cleanup-all.sh' }}"
changed_when: false
- name: configure sys-ctl-cln-faild-bkps{{ SYS_SERVICE_SUFFIX }}
template:
src: sys-ctl-cln-faild-bkps.service.j2
dest: /etc/systemd/system/sys-ctl-cln-faild-bkps{{ SYS_SERVICE_SUFFIX }}
notify: Reload sys-ctl-cln-faild-bkps service
- name: "set 'service_name' to '{{ role_name }}'"
set_fact:
service_name: "{{ role_name }}"
- name: "include role for sys-timer for {{ service_name }}"
include_role:
name: sys-timer
- include_role:
name: sys-systemctl
vars:
on_calendar: "{{SYS_SCHEDULE_CLEANUP_FAILED_BACKUPS}}"
systemctl_timer_enabled: true
systemctl_on_calendar: "{{SYS_SCHEDULE_CLEANUP_FAILED_BACKUPS}}"

View File

@@ -1,8 +0,0 @@
[Unit]
Description=Cleaning up failed docker volume backups
OnFailure=sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%n.service
[Service]
Type=oneshot
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{SYS_SERVICE_GROUP_CLEANUP| join(' ') }} --timeout "{{SYS_TIMEOUT_CLEANUP_SERVICES}}"'
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bash {{backup_docker_to_local_cleanup_script}}'

View File

@@ -0,0 +1,8 @@
[Unit]
Description=Cleaning up failed docker volume backups
OnFailure={{ SYS_SERVICE_ON_FAILURE_COMPOSE }}
[Service]
Type=oneshot
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{ SYS_SERVICE_GROUP_CLEANUP| join(' ') }} --timeout "{{ SYS_TIMEOUT_CLEANUP_SERVICES }}"'
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bash {{ BACKUP_CLEANUP_SCRIPT }}'

View File

@@ -1,2 +1,2 @@
cln_failed_docker_backups_pkg: cleanup-failed-docker-backups
systemctl_id: sys-ctl-cln-faild-bkps
CLN_FAILED_DOCKER_BACKUPS_PKG: cleanup-failed-docker-backups