mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-10-31 10:19:09 +00:00 
			
		
		
		
	Another big round of refactoring and cleaning...
This commit is contained in:
		
							
								
								
									
										24
									
								
								roles/sys-rpr-btrfs-blnc/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								roles/sys-rpr-btrfs-blnc/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| # System Btrfs Auto Balancer | ||||
|  | ||||
| ## Description | ||||
|  | ||||
| This role automates the management and balancing of Btrfs file systems. It clones the latest version of the [auto-btrfs-balancer](https://github.com/kevinveenbirkenbach/auto-btrfs-balancer.git) repository and configures a systemd service and timer to run the balancing script automatically. | ||||
|  | ||||
| ## Overview | ||||
|  | ||||
| Optimized for automated file system management, this role: | ||||
| - Clones the auto-btrfs-balancer repository. | ||||
| - Configures a systemd service to run the balancing script. | ||||
| - Integrates a systemd timer for regular execution. | ||||
| - Notifies via systemd in case of errors during the balancing process. | ||||
|  | ||||
| ## Purpose | ||||
|  | ||||
| The primary purpose of this role is to maintain optimal performance of Btrfs file systems by automating balancing tasks, ensuring efficient storage allocation and performance. | ||||
|  | ||||
| ## Features | ||||
|  | ||||
| - **Repository Cloning:** Automatically fetches the latest auto-btrfs-balancer repository. | ||||
| - **Service Configuration:** Sets up a systemd service for running the balancing script. | ||||
| - **Timer Integration:** Schedules the balancing process via a systemd timer. | ||||
| - **Error Notification:** Notifies on failure using sys-alm-compose. | ||||
							
								
								
									
										4
									
								
								roles/sys-rpr-btrfs-blnc/handlers/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								roles/sys-rpr-btrfs-blnc/handlers/main.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| - name: "reload sys-rpr-btrfs-blnc.cymais.service" | ||||
|   systemd: | ||||
|     name: sys-rpr-btrfs-blnc.cymais.service | ||||
|     daemon_reload: yes | ||||
							
								
								
									
										25
									
								
								roles/sys-rpr-btrfs-blnc/meta/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								roles/sys-rpr-btrfs-blnc/meta/main.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| --- | ||||
| galaxy_info: | ||||
|   author: "Kevin Veen-Birkenbach" | ||||
|   description: "Automates the balancing of Btrfs file systems by cloning the auto-btrfs-balancer repository and configuring a systemd service and timer for regular execution." | ||||
|   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: Archlinux | ||||
|       versions: | ||||
|         - rolling | ||||
|   galaxy_tags: | ||||
|     - btrfs | ||||
|     - balancing | ||||
|     - filesystem | ||||
|     - automation | ||||
|   repository: "https://s.veen.world/cymais" | ||||
|   issue_tracker_url: "https://s.veen.world/cymaisissues" | ||||
|   documentation: "https://s.veen.world/cymais" | ||||
| dependencies: | ||||
|   - sys-alm-compose | ||||
							
								
								
									
										30
									
								
								roles/sys-rpr-btrfs-blnc/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								roles/sys-rpr-btrfs-blnc/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| - name: "pkgmgr install" | ||||
|   include_role: | ||||
|     name: pkgmgr-install | ||||
|   vars: | ||||
|     package_name: btrfs-auto-balancer | ||||
|   when: run_once_system_btrfs_auto_balancer is not defined | ||||
|  | ||||
| - name: configure sys-rpr-btrfs-blnc.cymais.service | ||||
|   template:  | ||||
|     src: sys-rpr-btrfs-blnc.service.j2 | ||||
|     dest: /etc/systemd/system/sys-rpr-btrfs-blnc.cymais.service | ||||
|   notify: reload sys-rpr-btrfs-blnc.cymais.service | ||||
|   when: run_once_system_btrfs_auto_balancer is not defined | ||||
|  | ||||
| - name: "set 'service_name' to '{{ role_name }}'" | ||||
|   set_fact: | ||||
|     service_name: "{{ role_name }}" | ||||
|   when: run_once_system_btrfs_auto_balancer is not defined | ||||
|  | ||||
| - name: "include role for sys-timer for {{service_name}}" | ||||
|   include_role: | ||||
|     name: sys-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=sys-alm-compose.cymais@%n.service | ||||
|  | ||||
| [Service] | ||||
| Type=oneshot | ||||
| ExecStart=/bin/sh -c 'btrfs-auto-balancer 90 10' | ||||
							
								
								
									
										2
									
								
								roles/sys-rpr-btrfs-blnc/vars/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								roles/sys-rpr-btrfs-blnc/vars/main.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| system_btrfs_auto_balancer_folder: '{{path_administrator_scripts}}auto-btrfs-balancer/' | ||||
|  | ||||
		Reference in New Issue
	
	Block a user