mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-26 21:45:20 +02:00
refactor(services): unify service/timer runtime control and cleanup handling
- Introduce SYS_SERVICE_ALL_ENABLED and SYS_TIMER_ALL_ENABLED runtime flags - Add SYS_SERVICE_DEFAULT_STATE for consistent default handling - Ensure all on-failure service names use lowercase software_name - Load sys-svc-cln-anon-volumes role during Docker cleanup - Allow forced service refresh when SYS_SERVICE_ALL_ENABLED is true - Replace ACTIVATE_ALL_TIMERS with SYS_TIMER_ALL_ENABLED - Use SYS_SERVICE_DEFAULT_STATE in sys-systemctl vars - Remove redundant MIG build job fail check Related to service/timer process control refactoring.
This commit is contained in:
parent
3114a7b586
commit
630fd43382
@ -2,7 +2,9 @@
|
|||||||
# Services
|
# Services
|
||||||
|
|
||||||
## Meta
|
## Meta
|
||||||
SYS_SERVICE_SUFFIX: ".{{ SOFTWARE_NAME | lower }}.service"
|
SYS_SERVICE_SUFFIX: ".{{ SOFTWARE_NAME | lower }}.service"
|
||||||
|
SYS_SERVICE_ALL_ENABLED: false # Flush all services
|
||||||
|
SYS_SERVICE_DEFAULT_STATE: "{{ omit }}"
|
||||||
|
|
||||||
## Names
|
## Names
|
||||||
SYS_SERVICE_CLEANUP_BACKUPS_OLD: "{{ 'sys-ctl-cln-backups' | get_service_name(SOFTWARE_NAME) }}"
|
SYS_SERVICE_CLEANUP_BACKUPS_OLD: "{{ 'sys-ctl-cln-backups' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
@ -13,9 +15,9 @@ SYS_SERVICE_REPAIR_DOCKER_HARD: "{{ 'sys-ctl-rpr-docker-hard' | get_servic
|
|||||||
SYS_SERVICE_UPDATE_DOCKER: "{{ 'update-docker' | get_service_name(SOFTWARE_NAME) }}"
|
SYS_SERVICE_UPDATE_DOCKER: "{{ 'update-docker' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
|
|
||||||
## On Failure
|
## On Failure
|
||||||
SYS_SERVICE_ON_FAILURE_COMPOSE: "sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%i.service"
|
SYS_SERVICE_ON_FAILURE_COMPOSE: "sys-ctl-alm-compose.{{ SOFTWARE_NAME | lower }}@%i.service"
|
||||||
SYS_SERVICE_ON_FAILURE_EMAIL: "sys-ctl-alm-email.{{ SOFTWARE_NAME }}@%i.service"
|
SYS_SERVICE_ON_FAILURE_EMAIL: "sys-ctl-alm-email.{{ SOFTWARE_NAME | lower }}@%i.service"
|
||||||
SYS_SERVICE_ON_FAILURE_TELEGRAM: "sys-ctl-alm-telegram.{{ SOFTWARE_NAME }}@%i.service"
|
SYS_SERVICE_ON_FAILURE_TELEGRAM: "sys-ctl-alm-telegram.{{ SOFTWARE_NAME | lower }}@%i.service"
|
||||||
|
|
||||||
## Groups
|
## Groups
|
||||||
SYS_SERVICE_GROUP_BACKUPS: >
|
SYS_SERVICE_GROUP_BACKUPS: >
|
||||||
|
@ -2,15 +2,14 @@
|
|||||||
# Service Timers
|
# Service Timers
|
||||||
|
|
||||||
## Meta
|
## Meta
|
||||||
SYS_TIMER_SUFFIX: ".{{ SOFTWARE_NAME | lower }}.timer"
|
SYS_TIMER_SUFFIX: ".{{ SOFTWARE_NAME | lower }}.timer"
|
||||||
|
SYS_TIMER_ALL_ENABLED: false # Runtime Variables for Process Control - Activates all timers, independend if the handlers had been triggered
|
||||||
|
|
||||||
## Server Tact Variables
|
## Server Tact Variables
|
||||||
|
|
||||||
HOURS_SERVER_AWAKE: "0..23" # Ours in which the server is "awake" (100% working). Rest of the time is reserved for maintanance
|
HOURS_SERVER_AWAKE: "0..23" # Ours in which the server is "awake" (100% working). Rest of the time is reserved for maintanance
|
||||||
RANDOMIZED_DELAY_SEC: "5min" # Random delay for systemd timers to avoid peak loads.
|
RANDOMIZED_DELAY_SEC: "5min" # Random delay for systemd timers to avoid peak loads.
|
||||||
|
|
||||||
ACTIVATE_ALL_TIMERS: false # Runtime Variables for Process Control - Activates all timers, independend if the handlers had been triggered
|
|
||||||
|
|
||||||
## Timeouts for all services
|
## Timeouts for all services
|
||||||
SYS_TIMEOUT_CLEANUP_SERVICES: "15min"
|
SYS_TIMEOUT_CLEANUP_SERVICES: "15min"
|
||||||
SYS_TIMEOUT_STORAGE_OPTIMIZER: "10min"
|
SYS_TIMEOUT_STORAGE_OPTIMIZER: "10min"
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
- name: Load role to delete anonymous volumes
|
||||||
|
include_role:
|
||||||
|
name: sys-svc-cln-anon-volumes
|
||||||
|
|
||||||
- name: Prune Docker resources
|
- name: Prune Docker resources
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.command: docker system prune -f
|
ansible.builtin.command: docker system prune -f
|
@ -36,3 +36,10 @@
|
|||||||
src: "{{ systemctl_template_src }}"
|
src: "{{ systemctl_template_src }}"
|
||||||
dest: "{{ [ PATH_SYSTEM_SERVICE_DIR, systemctl_id | get_service_name(SOFTWARE_NAME) ] | path_join }}"
|
dest: "{{ [ PATH_SYSTEM_SERVICE_DIR, systemctl_id | get_service_name(SOFTWARE_NAME) ] | path_join }}"
|
||||||
notify: "{{ 'reload system daemon' if systemctl_uses_at else 'refresh systemctl service' }}"
|
notify: "{{ 'reload system daemon' if systemctl_uses_at else 'refresh systemctl service' }}"
|
||||||
|
|
||||||
|
- name: refresh systemctl service when SYS_SERVICE_ALL_ENABLED
|
||||||
|
command: /bin/true
|
||||||
|
notify: "refresh systemctl service"
|
||||||
|
when:
|
||||||
|
- SYS_SERVICE_ALL_ENABLED | bool
|
||||||
|
- not systemctl_uses_at
|
||||||
|
@ -8,4 +8,4 @@ systemctl_script_dir: "{{ [ PATH_SYSTEMCTL_SCRIPTS, systemctl_id ] | path_jo
|
|||||||
## Settings
|
## Settings
|
||||||
systemctl_copy_files: true # When set to false file copying will be skipped
|
systemctl_copy_files: true # When set to false file copying will be skipped
|
||||||
systemctl_timer_enabled: false # When set to true timmer will be loaded
|
systemctl_timer_enabled: false # When set to true timmer will be loaded
|
||||||
systemctl_state: "{{ omit }}"
|
systemctl_state: "{{ SYS_SERVICE_DEFAULT_STATE }}"
|
@ -12,6 +12,6 @@
|
|||||||
name: "{{ sys_timer_file }}"
|
name: "{{ sys_timer_file }}"
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: dummy_timer.changed or ACTIVATE_ALL_TIMERS | bool
|
when: dummy_timer.changed or SYS_TIMER_ALL_ENABLED | bool
|
||||||
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
|
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
|
||||||
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
|
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
|
||||||
|
@ -6,9 +6,3 @@
|
|||||||
async: "{{ (3600 if ASYNC_ENABLED | bool else omit) | default(omit) }}"
|
async: "{{ (3600 if ASYNC_ENABLED | bool else omit) | default(omit) }}"
|
||||||
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
|
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
|
||||||
register: mig_build_job
|
register: mig_build_job
|
||||||
|
|
||||||
- name: Fail if MIG build job did not start
|
|
||||||
fail:
|
|
||||||
msg: >
|
|
||||||
MIG build job failed to start. No job ID returned.
|
|
||||||
when: mig_build_job.ansible_job_id is not defined
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user