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,4 +0,0 @@
- name: "reload svc-bkp-rmt-2-loc service"
systemd:
name: svc-bkp-rmt-2-loc{{ SYS_SERVICE_SUFFIX }}
daemon_reload: yes

View File

@@ -23,5 +23,4 @@ galaxy_info:
issue_tracker_url: "https://s.infinito.nexus/issues"
documentation: "https://docs.infinito.nexus"
dependencies:
- sys-timer-cln-bkps
- sys-ctl-cln-faild-bkps

View File

@@ -6,41 +6,25 @@
- dev-git
- sys-ctl-alm-compose
- sys-lock
- sys-rst-daemon
- sys-timer-cln-bkps
- include_tasks: utils/run_once.yml
when: run_once_svc_bkp_rmt_2_loc is not defined
- name: "create {{docker_backup_remote_to_local_folder}}"
- name: "create {{ DOCKER_BACKUP_REMOTE_2_LOCAL_DIR }}"
file:
path: "{{docker_backup_remote_to_local_folder}}"
path: "{{ DOCKER_BACKUP_REMOTE_2_LOCAL_DIR }}"
state: directory
mode: "0755"
- name: create svc-bkp-rmt-2-loc.sh
copy:
src: svc-bkp-rmt-2-loc.sh
dest: "{{docker_backup_remote_to_local_folder}}svc-bkp-rmt-2-loc.sh"
dest: "{{ DOCKER_BACKUP_REMOTE_2_LOCAL_DIR }}svc-bkp-rmt-2-loc.sh"
mode: "0755"
- name: create svc-bkp-rmt-2-loc{{ SYS_SERVICE_SUFFIX }}
template:
src: svc-bkp-rmt-2-loc.service.j2
dest: /etc/systemd/system/svc-bkp-rmt-2-loc{{ SYS_SERVICE_SUFFIX }}
notify: reload svc-bkp-rmt-2-loc service
- name: create sys-bkp-rmt-2-loc-multi-provider.sh
template:
src: sys-bkp-rmt-2-loc-multi-provider.sh.j2
dest: "{{docker_backup_remote_to_local_folder}}sys-bkp-rmt-2-loc-multi-provider.sh"
mode: "0755"
- 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_BACKUP_REMOTE_TO_LOCAL}}"
systemctl_timer_enabled: true
systemctl_on_calendar: "{{ SYS_SCHEDULE_BACKUP_REMOTE_TO_LOCAL }}"

View File

@@ -3,6 +3,6 @@
hosts="{{ rmt2loc_backup_providers | join(' ') }}";
errors=0
for host in $hosts; do
bash {{ docker_backup_remote_to_local_folder }}svc-bkp-rmt-2-loc.sh $host || ((errors+=1));
bash {{ DOCKER_BACKUP_REMOTE_2_LOCAL_DIR }}svc-bkp-rmt-2-loc.sh $host || ((errors+=1));
done;
exit $errors;

View File

@@ -1,8 +0,0 @@
[Unit]
Description=pull remote backups
OnFailure=sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%n.service sys-ctl-cln-faild-bkps{{ SYS_SERVICE_SUFFIX }}
[Service]
Type=oneshot
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{SYS_SERVICE_GROUP_BACKUPS| join(' ') }} --timeout "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
ExecStart=/bin/sh -c '/usr/bin/bash {{docker_backup_remote_to_local_folder}}sys-bkp-rmt-2-loc-multi-provider.sh'

View File

@@ -0,0 +1,8 @@
[Unit]
Description=pull remote backups
OnFailure={{ SYS_SERVICE_ON_FAILURE_COMPOSE }} {{ SYS_SERVICE_CLEANUP_BACKUPS_FAILED }}
[Service]
Type=oneshot
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{ SYS_SERVICE_GROUP_BACKUPS| join(' ') }} --timeout "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
ExecStart=/bin/sh -c '/usr/bin/bash {{ systemctl_id | get_service_script_path('sh') }}'

View File

@@ -1,3 +1,4 @@
application_id: svc-bkp-rmt-2-loc
docker_backup_remote_to_local_folder: '{{ PATH_ADMINISTRATOR_SCRIPTS }}{{ application_id }}/'
rmt2loc_backup_providers: "{{ applications | get_app_conf(application_id, 'backup_providers') }}"
application_id: svc-bkp-rmt-2-loc
systemctl_id: "{{ application_id }}"
DOCKER_BACKUP_REMOTE_2_LOCAL_DIR: '{{ PATH_ADMINISTRATOR_SCRIPTS }}{{ application_id }}/'
rmt2loc_backup_providers: "{{ applications | get_app_conf(application_id, 'backup_providers') }}"