mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
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:
24
roles/sys-ctl-cln-faild-bkps/README.md
Normal file
24
roles/sys-ctl-cln-faild-bkps/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Docker Volume Backup Cleanup Role
|
||||
|
||||
## Description
|
||||
|
||||
This role cleans up failed Docker backups by pulling a [Git repository](https://github.com/kevinveenbirkenbach/sys-ctl-cln-faild-bkps) that contains cleanup scripts and configuring a systemd service to execute them. It ensures that failed or incomplete backups are removed to free up disk space and maintain a healthy backup environment.
|
||||
|
||||
## Overview
|
||||
|
||||
Optimized for backup maintenance, this role:
|
||||
- Clones the sys-ctl-cln-faild-bkps repository.
|
||||
- Configures a systemd service to run the cleanup script.
|
||||
- Integrates with the [sys-timer](../sys-timer/README.md) role to schedule periodic cleanup.
|
||||
- Works in conjunction with the sys-svc-directory-validator role for additional verification.
|
||||
|
||||
## Purpose
|
||||
|
||||
The primary purpose of this role is to remove failed Docker backups automatically, thereby freeing disk space and preventing backup storage from becoming cluttered with incomplete data.
|
||||
|
||||
## Features
|
||||
|
||||
- **Repository Cloning:** Retrieves the latest cleanup scripts from a Git repository.
|
||||
- **Service Configuration:** Sets up a systemd service to run the cleanup tasks.
|
||||
- **Timer Integration:** Schedules periodic cleanup through a systemd timer.
|
||||
- **Dependency Integration:** Works with sys-svc-directory-validator to enhance backup integrity.
|
5
roles/sys-ctl-cln-faild-bkps/handlers/main.yml
Normal file
5
roles/sys-ctl-cln-faild-bkps/handlers/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
- name: "Reload sys-ctl-cln-faild-bkps service"
|
||||
systemd:
|
||||
name: sys-ctl-cln-faild-bkps{{ SYS_SERVICE_SUFFIX }}
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
22
roles/sys-ctl-cln-faild-bkps/meta/main.yml
Normal file
22
roles/sys-ctl-cln-faild-bkps/meta/main.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
galaxy_info:
|
||||
author: "Kevin Veen-Birkenbach"
|
||||
description: "Cleans up failed Docker backups by configuring a systemd service and timer to execute the cleanup operations periodically."
|
||||
license: "Infinito.Nexus NonCommercial License"
|
||||
license_url: "https://s.infinito.nexus/license"
|
||||
company: |
|
||||
Kevin Veen-Birkenbach
|
||||
Consulting & Coaching Solutions
|
||||
https://www.veen.world
|
||||
min_ansible_version: "2.9"
|
||||
platforms:
|
||||
- name: Linux
|
||||
versions:
|
||||
- all
|
||||
galaxy_tags:
|
||||
- docker
|
||||
- backup
|
||||
- cleanup
|
||||
- automation
|
||||
repository: "https://s.infinito.nexus/code"
|
||||
issue_tracker_url: "https://s.infinito.nexus/issues"
|
||||
documentation: "https://docs.infinito.nexus"
|
40
roles/sys-ctl-cln-faild-bkps/tasks/01_core.yml
Normal file
40
roles/sys-ctl-cln-faild-bkps/tasks/01_core.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
- name: Include dependencies
|
||||
include_role:
|
||||
name: '{{ item }}'
|
||||
loop:
|
||||
- sys-ctl-alm-compose
|
||||
- sys-lock
|
||||
- sys-svc-directory-validator
|
||||
- sys-rst-daemon
|
||||
|
||||
- name: "pkgmgr install"
|
||||
include_role:
|
||||
name: pkgmgr-install
|
||||
vars:
|
||||
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 }}"
|
||||
register: pkgmgr_output
|
||||
changed_when: false
|
||||
|
||||
- name: Set fact for backup_docker_to_local_cleanup_script
|
||||
set_fact:
|
||||
backup_docker_to_local_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
|
||||
vars:
|
||||
on_calendar: "{{SYS_SCHEDULE_CLEANUP_FAILED_BACKUPS}}"
|
4
roles/sys-ctl-cln-faild-bkps/tasks/main.yml
Normal file
4
roles/sys-ctl-cln-faild-bkps/tasks/main.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
- block:
|
||||
- include_tasks: 01_core.yml
|
||||
- include_tasks: utils/run_once.yml
|
||||
when: run_once_sys_ctl_cln_faild_bkps is not defined
|
@@ -0,0 +1,8 @@
|
||||
[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}}'
|
2
roles/sys-ctl-cln-faild-bkps/vars/main.yml
Normal file
2
roles/sys-ctl-cln-faild-bkps/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
cln_failed_docker_backups_pkg: cleanup-failed-docker-backups
|
||||
|
Reference in New Issue
Block a user