From c785f4fc2803bfaf3bd2ccc67a952a048000cc3c Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Thu, 15 Jun 2023 08:55:57 +0200 Subject: [PATCH] Allow WorkingDirectory to be specified in [Service] Support use of `WorkingDirectory` directive in `[Service]` section of `systemd::manage_unit` and `systemd::manage_dropin` https://www.freedesktop.org/software/systemd/man/systemd.exec.html#WorkingDirectory= Fixes: #299 --- REFERENCE.md | 1 + spec/type_aliases/systemd_unit_service_spec.rb | 5 +++++ types/unit/service.pp | 1 + 3 files changed, 7 insertions(+) diff --git a/REFERENCE.md b/REFERENCE.md index 5707b02e..9e07a9d2 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -2316,6 +2316,7 @@ Struct[{ Optional['AmbientCapabilities'] => Variant[Pattern[/^CAP_[A-Z_]+$/],Array[Pattern[/^CAP_[A-Z_]+$/],1]], Optional['User'] => String[1], Optional['Group'] => String[1], + Optional['WorkingDirectory'] => String[0], Optional['Type'] => Enum['simple', 'exec', 'forking', 'oneshot', 'dbus', 'notify', 'idle'], Optional['ExitType'] => Enum['main', 'cgroup'], Optional['RemainAfterExit'] => Boolean, diff --git a/spec/type_aliases/systemd_unit_service_spec.rb b/spec/type_aliases/systemd_unit_service_spec.rb index 505a185a..d4f1eecd 100644 --- a/spec/type_aliases/systemd_unit_service_spec.rb +++ b/spec/type_aliases/systemd_unit_service_spec.rb @@ -44,4 +44,9 @@ it { is_expected.to allow_value({ 'Group' => 'root' }) } it { is_expected.to allow_value({ 'StandardOutput' => 'null' }) } it { is_expected.to allow_value({ 'StandardError' => 'null' }) } + + it { is_expected.to allow_value({ 'WorkingDirectory' => '/var/lib/here' }) } + it { is_expected.to allow_value({ 'WorkingDirectory' => '-/var/lib/here' }) } + it { is_expected.to allow_value({ 'WorkingDirectory' => '~' }) } + it { is_expected.to allow_value({ 'WorkingDirectory' => '' }) } end diff --git a/types/unit/service.pp b/types/unit/service.pp index e92bc854..63bd1e3e 100644 --- a/types/unit/service.pp +++ b/types/unit/service.pp @@ -7,6 +7,7 @@ Optional['AmbientCapabilities'] => Variant[Pattern[/^CAP_[A-Z_]+$/],Array[Pattern[/^CAP_[A-Z_]+$/],1]], Optional['User'] => String[1], Optional['Group'] => String[1], + Optional['WorkingDirectory'] => String[0], Optional['Type'] => Enum['simple', 'exec', 'forking', 'oneshot', 'dbus', 'notify', 'idle'], Optional['ExitType'] => Enum['main', 'cgroup'], Optional['RemainAfterExit'] => Boolean,