From bae2bc21ec695613e88927db8174fec801a2352a Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 27 Aug 2025 17:34:59 +0200 Subject: [PATCH] Optimized system services included suppress option and solved bugs --- roles/sys-ctl-hlth-journalctl/tasks/01_core.yml | 7 ++++--- roles/sys-ctl-rpr-btrfs-balancer/tasks/01_core.yml | 9 +++++---- .../templates/systemctl.service.j2 | 7 ------- roles/sys-service/defaults/main.yml | 3 ++- roles/sys-service/tasks/05_service.yml | 2 +- roles/sys-service/vars/main.yml | 7 ++++--- 6 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 roles/sys-ctl-rpr-btrfs-balancer/templates/systemctl.service.j2 diff --git a/roles/sys-ctl-hlth-journalctl/tasks/01_core.yml b/roles/sys-ctl-hlth-journalctl/tasks/01_core.yml index 7e32d99b..6c9d4b76 100644 --- a/roles/sys-ctl-hlth-journalctl/tasks/01_core.yml +++ b/roles/sys-ctl-hlth-journalctl/tasks/01_core.yml @@ -6,6 +6,7 @@ - include_role: name: sys-service vars: - system_service_on_calendar: "{{SYS_SCHEDULE_HEALTH_JOURNALCTL}}" - system_service_timer_enabled: true - system_service_tpl_on_failure: "{{ SYS_SERVICE_ON_FAILURE_COMPOSE }}" + system_service_on_calendar: "{{ SYS_SCHEDULE_HEALTH_JOURNALCTL }}" + system_service_timer_enabled: true + system_service_tpl_on_failure: "{{ SYS_SERVICE_ON_FAILURE_COMPOSE }}" +# system_service_suppress_flush: true # There are almost allways errors in the journalctl logs so suppression is neccessary to let playbook run diff --git a/roles/sys-ctl-rpr-btrfs-balancer/tasks/01_core.yml b/roles/sys-ctl-rpr-btrfs-balancer/tasks/01_core.yml index e61b34ba..e88f954e 100644 --- a/roles/sys-ctl-rpr-btrfs-balancer/tasks/01_core.yml +++ b/roles/sys-ctl-rpr-btrfs-balancer/tasks/01_core.yml @@ -12,7 +12,8 @@ - include_role: name: sys-service vars: - system_service_copy_files: false - system_service_on_calendar: "{{SYS_SCHEDULE_REPAIR_BTRFS_AUTO_BALANCER}}" - system_service_timer_enabled: true - system_service_tpl_on_failure: "{{ SYS_SERVICE_ON_FAILURE_COMPOSE }}" + system_service_copy_files: false + system_service_on_calendar: "{{ SYS_SCHEDULE_REPAIR_BTRFS_AUTO_BALANCER }}" + system_service_timer_enabled: true + system_service_tpl_on_failure: "{{ SYS_SERVICE_ON_FAILURE_COMPOSE }}" + system_service_tpl_exec_start: "/bin/sh -c 'btrfs-auto-balancer 90 10'" \ No newline at end of file diff --git a/roles/sys-ctl-rpr-btrfs-balancer/templates/systemctl.service.j2 b/roles/sys-ctl-rpr-btrfs-balancer/templates/systemctl.service.j2 deleted file mode 100644 index 7996ce47..00000000 --- a/roles/sys-ctl-rpr-btrfs-balancer/templates/systemctl.service.j2 +++ /dev/null @@ -1,7 +0,0 @@ -[Unit] -Description=auto balance btrfs -OnFailure={{ SYS_SERVICE_ON_FAILURE_COMPOSE }} - -[Service] -Type=oneshot -ExecStart=/bin/sh -c 'btrfs-auto-balancer 90 10' \ No newline at end of file diff --git a/roles/sys-service/defaults/main.yml b/roles/sys-service/defaults/main.yml index da5b6d3f..b1729647 100644 --- a/roles/sys-service/defaults/main.yml +++ b/roles/sys-service/defaults/main.yml @@ -1,3 +1,4 @@ SYS_SERVICE_ALL_ENABLED: "{{ MODE_DEBUG }}" SYS_SERVICE_DEFAULT_STATE: "{{ 'restarted' if MODE_DEBUG else omit }}" -SYS_SERVICE_DEFAULT_RUNTIME: "86400s" # Maximum total runtime a service is allowed to run before being stopped \ No newline at end of file +SYS_SERVICE_DEFAULT_RUNTIME: "86400s" # Maximum total runtime a service is allowed to run before being stopped +SYS_SERVICE_SUPPRESS_FLUSH: [] # Services where the flush should be suppressed \ No newline at end of file diff --git a/roles/sys-service/tasks/05_service.yml b/roles/sys-service/tasks/05_service.yml index ae9195b5..9d3eb5e9 100644 --- a/roles/sys-service/tasks/05_service.yml +++ b/roles/sys-service/tasks/05_service.yml @@ -46,5 +46,5 @@ command: /bin/true notify: refresh systemctl service when: not system_service_uses_at - when: SYS_SERVICE_ALL_ENABLED | bool or system_force_flush | bool + when: (SYS_SERVICE_ALL_ENABLED | bool or system_force_flush | bool) and not system_service_suppress_flush | bool diff --git a/roles/sys-service/vars/main.yml b/roles/sys-service/vars/main.yml index 54a91166..bb8711d3 100644 --- a/roles/sys-service/vars/main.yml +++ b/roles/sys-service/vars/main.yml @@ -6,9 +6,10 @@ system_service_role_dir: "{{ [ playbook_dir, 'roles', system_service_role_ system_service_script_dir: "{{ [ PATH_SYSTEMCTL_SCRIPTS, system_service_id ] | path_join }}" ## Settings -system_force_flush: false # When set to true it activates the flushing of services :) -system_service_copy_files: true # When set to false file copying will be skipped -system_service_timer_enabled: false # When set to true timer will be loaded +system_force_flush: false # When set to true it activates the flushing of services :) +system_service_suppress_flush: "{{ (system_service_id in SYS_SERVICE_SUPPRESS_FLUSH) | bool }}" # When set to true it suppresses the flushing of services +system_service_copy_files: true # When set to false file copying will be skipped +system_service_timer_enabled: false # When set to true timer will be loaded system_service_state: "{{ SYS_SERVICE_DEFAULT_STATE }}" # Dynamic Loaded ( Just available when dependencies are loaded )