Refactor systemctl services and categories due to alarm bugs

This commit restructures systemctl service definitions and category mappings.

Motivation: Alarm-related bugs revealed inconsistencies in service and role handling.

Preparation step: lays the groundwork for fixing the alarm issues by aligning categories, roles, and service templates.
This commit is contained in:
2025-08-18 13:35:43 +02:00
parent 29f50da226
commit 3a839cfe37
289 changed files with 975 additions and 948 deletions

View File

@@ -0,0 +1,37 @@
- name: Include dependencies
include_role:
name: '{{ item }}'
loop:
- sys-bkp-provider
- sys-ctl-alm-compose
- sys-lock
- sys-svc-directory-validator
- include_tasks: 02_pkgmgr_routines.yml
when: backup_docker_to_local_folder is not defined
- name: "reset (if enabled)"
include_tasks: 03_reset.yml
when: MODE_RESET | bool
- name: "setup '{{ BKP_DOCKER_2_LOC_SERVICE_ALL }}'"
template:
src: "{{ role_name }}-everything.service.j2"
dest: /etc/systemd/system/{{ BKP_DOCKER_2_LOC_SERVICE_ALL }}
notify: reload backup docker to local (all) service
- name: "setup '{{ BKP_DOCKER_2_LOC_SERVICE }}'"
template:
src: "{{ role_name }}.service.j2"
dest: /etc/systemd/system/{{ BKP_DOCKER_2_LOC_SERVICE }}
notify: reload backup docker to local 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
vars:
on_calendar: "{{SYS_SCHEDULE_BACKUP_DOCKER_TO_LOCAL}}"

View File

@@ -0,0 +1,19 @@
- block:
- name: "pkgmgr install {{ BKP_DOCKER_2_LOC_PKG }}"
include_role:
name: pkgmgr-install
vars:
package_name: "{{ BKP_DOCKER_2_LOC_PKG }}"
- name: "Retrieve {{ BKP_DOCKER_2_LOC_PKG }} path from pkgmgr"
command: "pkgmgr path {{ BKP_DOCKER_2_LOC_PKG }}"
register: pkgmgr_output
changed_when: false
- name: Set fact for backup_docker_to_local_folder
set_fact:
backup_docker_to_local_folder: "{{ pkgmgr_output.stdout }}/"
changed_when: false
when: backup_docker_to_local_folder is not defined
vars:
BKP_DOCKER_2_LOC_PKG: backup-docker-to-local

View File

@@ -0,0 +1,4 @@
- name: "reset {{ backup_docker_to_local_folder }}databases.csv"
file:
path: "{{ backup_docker_to_local_folder }}databases.csv"
state: absent

View File

@@ -0,0 +1,68 @@
- include_tasks: 02_pkgmgr_routines.yml
when: backup_docker_to_local_folder is not defined
- name: "Display all database variables"
debug:
msg: |
database_application_id: "{{ database_application_id | default('undefined') }}"
database_instance: "{{ database_instance | default('undefined') }}"
database_name: "{{ database_name | default('undefined') }}"
database_type: "{{ database_type | default('undefined') }}"
database_host: "{{ database_host | default('undefined') }}"
database_username: "{{ database_username | default('undefined') }}"
database_password: "{{ database_password | default('undefined') }}"
when: MODE_DEBUG | bool
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
- name: "fail if not all required database variables are defined"
fail:
msg: "You must define all of the following variables: database_instance, database_name, database_username, database_password"
when: >
(database_instance is defined or
database_name is defined or
database_username is defined or
database_password is defined) and not
(database_instance is defined and
database_name is defined and
database_username is defined and
database_password is defined)
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
- name: "seed database values in directory {{ backup_docker_to_local_folder }}"
command: >
python database_entry_seeder.py databases.csv
"{{ database_instance }}"
"{{ database_name }}"
"{{ database_username }}"
"{{ database_password }}"
args:
chdir: "{{ backup_docker_to_local_folder }}"
when:
- database_instance is defined
- database_name is defined
- database_username is defined
- database_password is defined
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
- name: Set file permissions for databases.csv to be readable, writable, and executable by root only
ansible.builtin.file:
path: "{{ backup_docker_to_local_folder }}databases.csv"
mode: '0700'
owner: root
group: root
when: >
(database_instance is defined and
database_name is defined and
database_username is defined and
database_password is defined) and
run_once_sys_ctl_bkp_docker_2_loc_file_permission is not defined
register: file_permission_result
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
- name: run the backup_docker_to_local_file_permission tasks once
set_fact:
run_once_sys_ctl_bkp_docker_2_loc_file_permission: true
when: run_once_sys_ctl_bkp_docker_2_loc_file_permission is not defined and file_permission_result is defined and file_permission_result.changed

View File

@@ -0,0 +1,10 @@
- block:
- include_tasks: 01_core.yml
- include_tasks: utils/run_once.yml
when:
- run_once_sys_ctl_bkp_docker_2_loc is not defined
- name: "include 04_seed-database-to-backup.yml"
include_tasks: 04_seed-database-to-backup.yml
when:
- BKP_DOCKER_2_LOC_DB_ENABLED | bool