Files
computer-playbook/roles/sys-ctl-cln-disc-space
Kevin Veen-Birkenbach 91ce097a0a feat(sys-service): migrate cleanup/backup services to generic units; harden disk-space cleanup
Services: add SYS_SERVICE_CLEANUP_BACKUPS and SYS_SERVICE_CLEANUP_DISC_SPACE in group vars.

sys-ctl-bkp-docker-2-loc: switch to sys-service; add ExecStartPre lock; ExecStartPost triggers backup cleanup; OnFailure → cleanup-failed; fix shell quoting.

sys-ctl-cln-bkps: switch to sys-service; pass CLI args via ExecStart; add ExecStartPre lock; set OnFailure; copy files; remove role-specific service template.

sys-ctl-cln-disc-space: switch to sys-service; enable timer; set OnFailure; provide ExecStart/ExecStartPre; copy files; remove role-specific service template.

script.sh (disc-space): non-interactive docker exec; consistent threshold message (use parameter); guard docker/pacman via command checks; robust container check; fix typo; use POSIX '='.

svc-opt-keyboard-color: minor formatting cleanup.

sys-ctl-hlth-disc-space: chain OnFailure to cleanup-disc-space service.

Context: ChatGPT conversation (Sep 10, 2025, Europe/Berlin) — https://chatgpt.com/share/68c1982e-bdc8-800f-bf13-a8b9f084f90e
2025-09-10 17:24:56 +02:00
..

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.