mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-10-31 10:19:09 +00:00 
			
		
		
		
	Implemented System Btrfs Auto Balancer Role
This commit is contained in:
		
							
								
								
									
										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/" | ||||
		Reference in New Issue
	
	Block a user