From d6f96aa0aab843917e39aa41f3415213a3a381b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20M=C3=B6ller?= Date: Thu, 7 Dec 2023 10:17:57 +0100 Subject: [PATCH] Make SystemD timer services configurable --- .../20231207_105555_nm_Make_timer_service_configurable.md | 1 + src/batou_ext/cron.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 CHANGES.d/20231207_105555_nm_Make_timer_service_configurable.md diff --git a/CHANGES.d/20231207_105555_nm_Make_timer_service_configurable.md b/CHANGES.d/20231207_105555_nm_Make_timer_service_configurable.md new file mode 100644 index 0000000..44471e6 --- /dev/null +++ b/CHANGES.d/20231207_105555_nm_Make_timer_service_configurable.md @@ -0,0 +1 @@ +Make it possible to add arbitrary additional configuration to a service created by a SystemdTimer(). diff --git a/src/batou_ext/cron.py b/src/batou_ext/cron.py index d331b2d..cbc91dc 100644 --- a/src/batou_ext/cron.py +++ b/src/batou_ext/cron.py @@ -135,6 +135,7 @@ class SystemdTimer(batou.component.Component): onCalendar = batou.component.Attribute(str) timeout = "1h" description = None + additional_service_config = None run_as = batou.component.Attribute( str, default=batou.component.ConfigString( @@ -186,6 +187,11 @@ def configure(self): User = "{{component.run_as}}"; ExecStart = "{{component.wrapped_command}}"; TimeoutStartSec = "{{component.timeout}}"; + {%- if component.additional_service_config is not none %} + {%- for setting, value in component.additional_service_config.items() %} + {{ setting }} = {{ value }}; + {%- endfor %} + {%- endif %} }; }; }