Files
computer-playbook/roles/sys-service/templates/systemctl.service.j2
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

41 lines
1.2 KiB
Django/Jinja

[Unit]
Description={{ SOFTWARE_NAME }} - Service for role '{{ system_service_id }}'
{% for key, val in [
('OnFailure', system_service_tpl_on_failure),
('After', system_service_tpl_after),
('Before', system_service_tpl_before),
('Wants', system_service_tpl_wants),
] %}
{% set directive = val | systemd_directive(key) %}
{% if directive %}
{{ directive }}
{% endif %}
{% endfor %}
StartLimitIntervalSec=60
StartLimitBurst=3
OnFailureJobMode=replace-irreversibly
[Service]
Type={{ system_service_tpl_type }}
{% for _environment in system_service_tpl_environment %}
Environment={{ _environment }}
{% endfor %}
{% for key, val in [
('RemainAfterExit', system_service_tpl_remain_after_exit),
('TimeoutStartSec', system_service_tpl_timeout_start_sec),
('ExecStartPre', system_service_tpl_exec_start_pre),
('ExecStart', system_service_tpl_exec_start),
('ExecStartPost', system_service_tpl_exec_start_post),
('RuntimeMaxSec', system_service_tpl_runtime),
] %}
{% set directive = val | systemd_directive(key) %}
{% if directive %}
{{ directive }}
{% endif %}
{% endfor %}
{% if system_service_tpl_wanted_by | length > 0 %}
[Install]
WantedBy={{ system_service_tpl_wanted_by }}
{% endif %}