mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-21 12:21:04 +01:00
Implemented System Btrfs Auto Balancer Role
This commit is contained in:
parent
0866b498ac
commit
f7a93a18d1
@ -49,7 +49,7 @@ on_calendar_renew_lets_encrypt_certificates: "*-*-* 12,00:30:00"
|
|||||||
on_calendar_deploy_mailu_certificates: "*-*-* 13,01:30:00" # Deploy Mailu certificates twice per day
|
on_calendar_deploy_mailu_certificates: "*-*-* 13,01:30:00" # Deploy Mailu certificates twice per day
|
||||||
on_calendar_msi_keyboard_color: "*-*-* *:*:00" # Change the keyboard color every minute
|
on_calendar_msi_keyboard_color: "*-*-* *:*:00" # Change the keyboard color every minute
|
||||||
on_calendar_cleanup_failed_docker: "*-*-* 12:00:00" # Clean up failed docker backups every noon
|
on_calendar_cleanup_failed_docker: "*-*-* 12:00:00" # Clean up failed docker backups every noon
|
||||||
|
on_calendar_btrfs_auto_balancer: "Sat *-*-01..07 00:00:00" # Execute btrfs auto balancer every first Saturday of a month
|
||||||
|
|
||||||
# Storage Space-Related Configurations
|
# Storage Space-Related Configurations
|
||||||
size_percent_maximum_backup: 75 # Maximum storage space in percent for backups
|
size_percent_maximum_backup: 75 # Maximum storage space in percent for backups
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
- health-disc-space
|
- health-disc-space
|
||||||
- cleanup-disc-space
|
- cleanup-disc-space
|
||||||
- health-btrfs
|
- health-btrfs
|
||||||
|
- system-btrfs-auto-balancer
|
||||||
|
|
||||||
|
|
||||||
# Docker Roles
|
# Docker Roles
|
||||||
- name: setup nextcloud hosts
|
- name: setup nextcloud hosts
|
||||||
|
30
roles/system-btrfs-auto-balancer/README.md
Normal file
30
roles/system-btrfs-auto-balancer/README.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# System Btrfs Auto Balancer Role 📦
|
||||||
|
|
||||||
|
This Ansible role automates the management and balancing of Btrfs file systems. It ensures that the Btrfs file system is maintained efficiently without manual intervention.
|
||||||
|
|
||||||
|
## Features ✨
|
||||||
|
|
||||||
|
- **Automatic Cloning of Repository:** Fetches the latest `auto-btrfs-balancer` repository from GitHub.
|
||||||
|
- **Systemd Service Configuration:** Creates and configures a Systemd service to automatically run the balancing script.
|
||||||
|
- **Systemd Timer Integration:** Integrates a Systemd timer to run the balancing service at regular intervals.
|
||||||
|
- **Error Notification:** Notifies via Systemd in case of errors during the balancing process.
|
||||||
|
|
||||||
|
## Prerequisites 📋
|
||||||
|
|
||||||
|
- **Ansible:** This role requires Ansible to run.
|
||||||
|
- **Systemd:** Target systems must support Systemd.
|
||||||
|
- **Git:** Git must be installed to clone the repository.
|
||||||
|
|
||||||
|
|
||||||
|
## Author ✍️
|
||||||
|
|
||||||
|
This role was created by [Kevin Veen-Birkenbach](https://www.veen.world).
|
||||||
|
- **Email:** kevin@veen.world
|
||||||
|
- **Website:** [veen.world](https://www.veen.world)
|
||||||
|
|
||||||
|
## Contact ☎️
|
||||||
|
|
||||||
|
For questions or support, you can reach Kevin Veen-Birkenbach via [email](mailto:kevin@veen.world).
|
||||||
|
|
||||||
|
## Created with AI
|
||||||
|
This README.md was created with the assistance of ChatGPT. You can view the conversation [here](https://chatgpt.com/share/dcec1b4a-c7a8-4cf8-a87a-987eb0500857).
|
4
roles/system-btrfs-auto-balancer/handlers/main.yml
Normal file
4
roles/system-btrfs-auto-balancer/handlers/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- name: "reload system-btrfs-auto-balancer.cymais.service"
|
||||||
|
systemd:
|
||||||
|
name: system-btrfs-auto-balancer.cymais.service
|
||||||
|
daemon_reload: yes
|
3
roles/system-btrfs-auto-balancer/meta/main.yml
Normal file
3
roles/system-btrfs-auto-balancer/meta/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dependencies:
|
||||||
|
- git
|
||||||
|
- systemd-notifier
|
31
roles/system-btrfs-auto-balancer/tasks/main.yml
Normal file
31
roles/system-btrfs-auto-balancer/tasks/main.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
- name: pull auto-btrfs-balancer.git
|
||||||
|
git:
|
||||||
|
repo: "https://github.com/kevinveenbirkenbach/auto-btrfs-balancer.git"
|
||||||
|
dest: "{{system_btrfs_auto_balancer_folder}}"
|
||||||
|
update: yes
|
||||||
|
ignore_errors: true
|
||||||
|
when: run_once_system_btrfs_auto_balancer is not defined
|
||||||
|
|
||||||
|
- name: configure system-btrfs-auto-balancer.cymais.service
|
||||||
|
template:
|
||||||
|
src: system-btrfs-auto-balancer.service.j2
|
||||||
|
dest: /etc/systemd/system/system-btrfs-auto-balancer.cymais.service
|
||||||
|
notify: reload system-btrfs-auto-balancer.cymais.service
|
||||||
|
when: run_once_system_btrfs_auto_balancer is not defined
|
||||||
|
|
||||||
|
- name: set service_name to the name of the current role
|
||||||
|
set_fact:
|
||||||
|
service_name: "{{ role_name }}"
|
||||||
|
when: run_once_system_btrfs_auto_balancer is not defined
|
||||||
|
|
||||||
|
- name: "include role for systemd-timer for {{service_name}}"
|
||||||
|
include_role:
|
||||||
|
name: systemd-timer
|
||||||
|
vars:
|
||||||
|
on_calendar: "{{on_calendar_btrfs_auto_balancer}}"
|
||||||
|
when: run_once_system_btrfs_auto_balancer is not defined
|
||||||
|
|
||||||
|
- name: run the system_btrfs_auto_balancer tasks once
|
||||||
|
set_fact:
|
||||||
|
run_once_system_btrfs_auto_balancer: true
|
||||||
|
when: run_once_system_btrfs_auto_balancer is not defined
|
@ -0,0 +1,7 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=auto balance btrfs
|
||||||
|
OnFailure=systemd-notifier.cymais@%n.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/bin/sh -c '/usr/bin/python {{system_btrfs_auto_balancer_folder}}main.py 90 10'
|
1
roles/system-btrfs-auto-balancer/vars/main.yml
Normal file
1
roles/system-btrfs-auto-balancer/vars/main.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
system_btrfs_auto_balancer_folder: "{{path_administrator_scripts}}auto-btrfs-balancer/"
|
Loading…
Reference in New Issue
Block a user