Implemented System Btrfs Auto Balancer Role

This commit is contained in:
2024-05-27 23:24:21 +02:00
parent 0866b498ac
commit f7a93a18d1
8 changed files with 79 additions and 1 deletions

View 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).

View File

@@ -0,0 +1,4 @@
- name: "reload system-btrfs-auto-balancer.cymais.service"
systemd:
name: system-btrfs-auto-balancer.cymais.service
daemon_reload: yes

View File

@@ -0,0 +1,3 @@
dependencies:
- git
- systemd-notifier

View 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

View File

@@ -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'

View File

@@ -0,0 +1 @@
system_btrfs_auto_balancer_folder: "{{path_administrator_scripts}}auto-btrfs-balancer/"