Files
computer-playbook/roles/sys-service/vars/main.yml
kevinveenbirkenbachandClaude Opus 5 99f7e03845 feat(sys-service): carry unit ordering, an Install section and a user scope
The generic unit template could express neither an ordering dependency nor an Install section, so a role needing either shipped its own templates/systemctl.service.j2 and re-answered the daemon reload, the enable and the flush behaviour by hand.

Add After, Before, Wants, RemainAfterExit and a WantedBy driven Install section, all inert at their defaults, and route the unit path, its owner, become and the systemctl probes through a system_service_scope so a per-login unit lands under the user's own systemd directory.

00_core is gated on the system scope rather than only its prune and lockdown steps: it sets run_once_sys_service, so a user-scope caller running first would otherwise skip the lockdown for every system-scope role behind it in the same play.

Rendering the previous template against the same inputs drops no directive and adds none; the only difference is the blank line an empty directive used to leave behind.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 18:09:43 +02:00

46 lines
3.1 KiB
YAML

---
UNIT_SUFFIX_REMOVER_PACKAGE: "unsure"
system_service_name: "{{ lookup('unit_name', system_service_id) }}"
system_service_is_template: "{{ system_service_id.endswith('@') }}"
system_service_scope: "system" # 'system' for root units, 'user' for per-login units
system_service_unit_dir: "{{ DIR_SYSTEM_SERVICE if system_service_scope == 'system' else DIR_SYSTEM_SERVICE_USER }}"
system_service_unit_owner: "{{ 'root' if system_service_scope == 'system' else omit }}"
system_service_unit_become: "{{ system_service_scope == 'system' }}"
system_service_systemctl_show: "{{ ['systemctl'] + (['--user'] if system_service_scope == 'user' else []) + ['--no-pager', 'show', '--value', '-p'] }}"
system_service_role_name: "{{ system_service_id | regex_replace('@','') }}"
system_service_role_dir: "{{ lookup('path_absolute', 'roles', system_service_role_name) }}"
system_service_script_dir: "{{ [ DIR_SCRIPTS_SYSTEMCTL, system_service_id ] | path_join }}"
system_service_force_linear_sync: "{{ system_service_name in SYS_SERVICE_GROUP_MANIPULATION }}" # Disables automatic async
system_service_force_flush_instant: "{{ (SYS_SERVICE_ALL_ENABLED | bool) and not system_service_force_flush_final }}" # When set to true it activates the flushing of services. defaults to SYS_SERVICE_ALL_ENABLED
system_service_force_flush_final: false # Force run at the end of the play
system_service_suppress_flush: "{{ system_service_force_flush_final | 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 }}"
system_service_async: "{{ omit if (system_service_force_linear_sync | bool or not ASYNC_ENABLED | bool) else ASYNC_TIME }}"
system_service_poll: "{{ omit if (system_service_force_linear_sync | bool or not ASYNC_ENABLED | bool) else ASYNC_POLL }}"
system_service_script_base: "{{ system_service_script_src | basename | regex_replace('\\.j2$', '') }}"
system_service_script_type: "{{ system_service_script_base | filetype }}"
system_service_script_inter: "{{ '/bin/bash' if system_service_script_type == 'sh' else ansible_python_interpreter }}"
system_service_script_exec: "{{ system_service_script_inter }} {{ system_service_id | get_service_script_path( system_service_script_type ) }}"
system_service_tpl_on_failure: "{{ SYS_SERVICE_ON_FAILURE_COMPOSE }}"
system_service_tpl_after: ""
system_service_tpl_before: ""
system_service_tpl_wants: ""
system_service_tpl_type: "oneshot"
system_service_tpl_remain_after_exit: ""
system_service_tpl_wanted_by: "" # Empty installs no [Install] section, which leaves the unit static
system_service_tpl_environment: [] # Environment variables
system_service_tpl_runtime: "{{ '' if system_service_tpl_type == 'oneshot' else SYS_SERVICE_DEFAULT_RUNTIME }}"
system_service_tpl_exec_start_pre: ""
system_service_tpl_exec_start: "{{ system_service_script_exec }}"
system_service_tpl_exec_start_post: ""
system_service_tpl_timeout_start_sec: "" # If not defined the default values from sys-daemon in manager will be used