From 17e2c992b323d383fb1ccb57a285012d726dc3b0 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 14 Mar 2025 13:48:15 +0100 Subject: [PATCH] Optimized .mds and meta/main.yml for cleanup roles --- .../cleanup-backups-service/Administration.md | 7 +++++ roles/cleanup-backups-service/README.md | 29 ++++++++++++++----- roles/cleanup-backups-service/meta/main.yml | 23 +++++++++++++++ roles/cleanup-backups-timer/README.md | 22 ++++++++++++-- roles/cleanup-backups-timer/meta/main.yml | 23 +++++++++++++++ roles/cleanup-disc-space/README.md | 28 +++++++++++++++--- roles/cleanup-disc-space/meta/main.yml | 23 +++++++++++++++ roles/cleanup-failed-docker-backups/README.md | 27 +++++++++++++++-- .../meta/main.yml | 23 +++++++++++++++ 9 files changed, 188 insertions(+), 17 deletions(-) create mode 100644 roles/cleanup-backups-service/Administration.md diff --git a/roles/cleanup-backups-service/Administration.md b/roles/cleanup-backups-service/Administration.md new file mode 100644 index 00000000..b1b8e547 --- /dev/null +++ b/roles/cleanup-backups-service/Administration.md @@ -0,0 +1,7 @@ +It may be neccessary to install gcc seperat to use psutil + +```bash + sudo pacman -S gcc +``` + +If this is the case in the future, automize it in this role. \ No newline at end of file diff --git a/roles/cleanup-backups-service/README.md b/roles/cleanup-backups-service/README.md index 659799d0..292e8134 100644 --- a/roles/cleanup-backups-service/README.md +++ b/roles/cleanup-backups-service/README.md @@ -1,14 +1,27 @@ -# role cleanup-backups-timer +# Cleanup Backups Service -Cleans up old backups +## Description -## Additional software +This role automates the cleanup of old backups by executing a Python script that deletes outdated backup versions based on disk usage thresholds. It ensures that backup storage does not exceed a defined usage percentage. -It may be neccessary to install gcc seperat to use psutil +## Overview -```bash - sudo pacman -S gcc -``` +Optimized for effective disk space management, this role: +- Installs required packages (e.g. [lsof](https://en.wikipedia.org/wiki/Lsof) and [psutil](https://pypi.org/project/psutil/)) using pacman. +- Creates a directory for storing cleanup scripts. +- Deploys a Python script that deletes old backup directories when disk usage is too high. +- Configures a systemd service to run the cleanup script, with notifications via [systemd-notifier](../systemd-notifier/README.md). -## further information +## Purpose + +The primary purpose of this role is to maintain optimal backup storage by automatically removing outdated backup versions when disk usage exceeds a specified threshold. + +## Features + +- **Automated Cleanup:** Executes a Python script to delete old backups. +- **Threshold-Based Deletion:** Removes backups based on disk usage percentage. +- **Systemd Integration:** Configures a systemd service to run cleanup tasks. +- **Dependency Integration:** Works in conjunction with related roles for comprehensive backup management. + +## Further Information - https://stackoverflow.com/questions/48929553/get-hard-disk-size-in-python \ No newline at end of file diff --git a/roles/cleanup-backups-service/meta/main.yml b/roles/cleanup-backups-service/meta/main.yml index bd8f1996..4a2cf034 100644 --- a/roles/cleanup-backups-service/meta/main.yml +++ b/roles/cleanup-backups-service/meta/main.yml @@ -1,3 +1,26 @@ +--- +galaxy_info: + author: "Kevin Veen-Birkenbach" + description: "Automates the cleanup of old backups by executing a Python script that deletes outdated backup versions when disk usage exceeds a specified threshold." + 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: + - backup + - cleanup + - disk + - automation + repository: "https://s.veen.world/cymais" + issue_tracker_url: "https://s.veen.world/cymaisissues" + documentation: "https://s.veen.world/cymais" dependencies: - python-pip - systemd-notifier diff --git a/roles/cleanup-backups-timer/README.md b/roles/cleanup-backups-timer/README.md index b619ba81..380cd458 100644 --- a/roles/cleanup-backups-timer/README.md +++ b/roles/cleanup-backups-timer/README.md @@ -1,3 +1,21 @@ -# role cleanup-backups-timer +# Cleanup Backups Timer -Timer for cleaning up old backups \ No newline at end of file +## Description + +This role sets up a systemd timer to schedule the periodic cleanup of old backups. It leverages the cleanup-backups-service role to perform the actual cleanup operation. + +## Overview + +Optimized for automated maintenance, this role: +- Sets a fact for the service name. +- Integrates with the [systemd-timer](../systemd-timer/README.md) role to schedule cleanup-backups tasks at defined intervals. + +## Purpose + +The primary purpose of this role is to automate the scheduling of backup cleanup operations using a systemd timer, ensuring that backup storage remains within defined limits. + +## Features + +- **Timer Scheduling:** Configures a systemd timer to trigger the backup cleanup service. +- **Role Integration:** Works in conjunction with the cleanup-backups-service role. +- **Idempotency:** Ensures the timer tasks execute only once per playbook run. diff --git a/roles/cleanup-backups-timer/meta/main.yml b/roles/cleanup-backups-timer/meta/main.yml index d17982fb..ff5df25d 100644 --- a/roles/cleanup-backups-timer/meta/main.yml +++ b/roles/cleanup-backups-timer/meta/main.yml @@ -1,2 +1,25 @@ +--- +galaxy_info: + author: "Kevin Veen-Birkenbach" + description: "Schedules periodic cleanup of old backups by configuring a systemd timer to trigger the cleanup-backups-service role." + 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: + - timer + - backup + - cleanup + - automation + repository: "https://s.veen.world/cymais" + issue_tracker_url: "https://s.veen.world/cymaisissues" + documentation: "https://s.veen.world/cymais" dependencies: - cleanup-backups-service diff --git a/roles/cleanup-disc-space/README.md b/roles/cleanup-disc-space/README.md index 8fdb66ea..f7828c5f 100644 --- a/roles/cleanup-disc-space/README.md +++ b/roles/cleanup-disc-space/README.md @@ -1,4 +1,24 @@ -# cleanup-disc-space -Frees disc space -## More information -- https://askubuntu.com/questions/380238/how-to-clean-tmp \ No newline at end of file +# Cleanup Disc Space + +## Description + +This role frees disk space by executing a script that cleans up temporary files, clears package caches, and optionally cleans up backup directories and Docker resources when disk usage exceeds a specified threshold. + +## Overview + +Optimized for efficient storage management, this role: +- Creates a directory for disk cleanup scripts. +- Deploys a Bash script that frees disk space by cleaning up /tmp, Docker resources, and pacman cache. +- Configures a systemd service to run the disk cleanup script. +- Optionally integrates with backup cleanup if backup variables are defined. + +## Purpose + +The primary purpose of this role is to ensure that disk space remains within safe limits by automating cleanup tasks, thereby improving system performance and stability. + +## Features + +- **Automated Cleanup:** Executes a script to remove temporary files and clear caches. +- **Threshold-Based Execution:** Triggers cleanup when disk usage exceeds a defined percentage. +- **Systemd Integration:** Configures a systemd service to manage the disk cleanup process. +- **Docker and Backup Integration:** Optionally cleans Docker resources and backups if configured. diff --git a/roles/cleanup-disc-space/meta/main.yml b/roles/cleanup-disc-space/meta/main.yml index a9080d44..2248a352 100644 --- a/roles/cleanup-disc-space/meta/main.yml +++ b/roles/cleanup-disc-space/meta/main.yml @@ -1,3 +1,26 @@ +--- +galaxy_info: + author: "Kevin Veen-Birkenbach" + description: "Frees disk space on the target system by executing a cleanup script that removes temporary files, clears package caches, and optionally handles Docker and backup cleanup." + 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: + - disk + - cleanup + - storage + - automation + repository: "https://s.veen.world/cymais" + issue_tracker_url: "https://s.veen.world/cymaisissues" + documentation: "https://s.veen.world/cymais" dependencies: - systemd-notifier - system-maintenance-lock diff --git a/roles/cleanup-failed-docker-backups/README.md b/roles/cleanup-failed-docker-backups/README.md index 3873e687..906904cc 100644 --- a/roles/cleanup-failed-docker-backups/README.md +++ b/roles/cleanup-failed-docker-backups/README.md @@ -1,3 +1,24 @@ -# Docker Volume Backup Cleanup -This script cleans up failed docker backups. -It uses https://github.com/kevinveenbirkenbach/cleanup-failed-docker-backups as base. \ No newline at end of file +# Docker Volume Backup Cleanup Role + +## Description + +This role cleans up failed Docker backups by pulling a [Git repository](https://github.com/kevinveenbirkenbach/cleanup-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 cleanup-failed-docker-backups repository. +- Configures a systemd service to run the cleanup script. +- Integrates with the [systemd-timer](../systemd-timer/README.md) role to schedule periodic cleanup. +- Works in conjunction with the backup-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 backup-directory-validator to enhance backup integrity. \ No newline at end of file diff --git a/roles/cleanup-failed-docker-backups/meta/main.yml b/roles/cleanup-failed-docker-backups/meta/main.yml index aa351d63..71a96c2f 100644 --- a/roles/cleanup-failed-docker-backups/meta/main.yml +++ b/roles/cleanup-failed-docker-backups/meta/main.yml @@ -1,3 +1,26 @@ +--- +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: - git - systemd-notifier