mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 23:08:06 +02:00
Shorted cleanup- to cln-
This commit is contained in:
24
roles/cln-failed-docker-backups/README.md
Normal file
24
roles/cln-failed-docker-backups/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/cln-failed-docker-backups) 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 cln-failed-docker-backups repository.
|
||||
- Configures a systemd service to run the cleanup script.
|
||||
- Integrates with the [generic-timer](../generic-timer/README.md) role to schedule periodic cleanup.
|
||||
- Works in conjunction with the bkp-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 bkp-directory-validator to enhance backup integrity.
|
5
roles/cln-failed-docker-backups/handlers/main.yml
Normal file
5
roles/cln-failed-docker-backups/handlers/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
- name: "Reload cln-failed-docker-backups.cymais.service"
|
||||
systemd:
|
||||
name: cln-failed-docker-backups.cymais.service
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
27
roles/cln-failed-docker-backups/meta/main.yml
Normal file
27
roles/cln-failed-docker-backups/meta/main.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
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: "CyMaIS NonCommercial License (CNCL)"
|
||||
license_url: "https://s.veen.world/cncl"
|
||||
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.veen.world/cymais"
|
||||
issue_tracker_url: "https://s.veen.world/cymaisissues"
|
||||
documentation: "https://s.veen.world/cymais"
|
||||
dependencies:
|
||||
- alert-compose
|
||||
- maint-lock
|
||||
- bkp-directory-validator
|
42
roles/cln-failed-docker-backups/tasks/main.yml
Normal file
42
roles/cln-failed-docker-backups/tasks/main.yml
Normal file
@@ -0,0 +1,42 @@
|
||||
- name: "pkgmgr install"
|
||||
include_role:
|
||||
name: pkgmgr-install
|
||||
vars:
|
||||
package_name: cln-failed-docker-backups
|
||||
when: run_once_cleanup_failed_docker_backups is not defined
|
||||
|
||||
- name: Retrieve bkp-docker-to-local path from pkgmgr
|
||||
command: pkgmgr path cln-failed-docker-backups
|
||||
register: pkgmgr_output
|
||||
changed_when: false
|
||||
when: run_once_cleanup_failed_docker_backups is not defined
|
||||
|
||||
- name: Set fact for backup_docker_to_local_cleanup_script
|
||||
set_fact:
|
||||
backup_docker_to_local_cleanup_script: "{{ pkgmgr_output.stdout.rstrip('/') ~ '/cln-all.sh' }}"
|
||||
changed_when: false
|
||||
when: run_once_cleanup_failed_docker_backups is not defined
|
||||
|
||||
- name: configure cln-failed-docker-backups.cymais.service
|
||||
template:
|
||||
src: cln-failed-docker-backups.service.j2
|
||||
dest: /etc/systemd/system/cln-failed-docker-backups.cymais.service
|
||||
notify: Reload cln-failed-docker-backups.cymais.service
|
||||
when: run_once_cleanup_failed_docker_backups is not defined
|
||||
|
||||
- name: set service_name to the name of the current role
|
||||
set_fact:
|
||||
service_name: "{{ role_name }}"
|
||||
when: run_once_cleanup_failed_docker_backups is not defined
|
||||
|
||||
- name: "include role for generic-timer for {{service_name}}"
|
||||
include_role:
|
||||
name: generic-timer
|
||||
vars:
|
||||
on_calendar: "{{on_calendar_cleanup_failed_docker}}"
|
||||
when: run_once_cleanup_failed_docker_backups is not defined
|
||||
|
||||
- name: run the cleanup_failed_docker_backups tasks once
|
||||
set_fact:
|
||||
run_once_cleanup_failed_docker_backups: true
|
||||
when: run_once_cleanup_failed_docker_backups is not defined
|
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Cleaning up failed docker volume backups
|
||||
OnFailure=alert-compose.cymais@%n.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ path_system_lock_script }} {{ system_maintenance_services | join(' ') }} --ignore {{system_maintenance_cleanup_services| join(' ') }} --timeout "{{system_maintenance_lock_timeout_backup_services}}"'
|
||||
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bash {{backup_docker_to_local_cleanup_script}}'
|
Reference in New Issue
Block a user