From 9554fde4f3b66db3d9f64f1514d33a2a826ccaa8 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 | 6 ++++++ types/unit/service.pp | 1 + 3 files changed, 8 insertions(+) diff --git a/REFERENCE.md b/REFERENCE.md index 8e118222..3693fe6a 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, 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 e65f5733..ede8370f 100644 --- a/spec/type_aliases/systemd_unit_service_spec.rb +++ b/spec/type_aliases/systemd_unit_service_spec.rb @@ -39,4 +39,10 @@ it { is_expected.to allow_value({ 'EnvironmentFile' => ['/etc/sysconfig/foo', '-/etc/sysconfig/foo-bar'] }) } it { is_expected.not_to allow_value({ 'EnvironmentFile' => '-/' }) } it { is_expected.not_to allow_value({ 'EnvironmentFile' => 'relative-path.sh' }) } + + 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 81b16bf0..64aceebf 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, Optional['Type'] => Enum['simple', 'exec', 'forking', 'oneshot', 'dbus', 'notify', 'idle'], Optional['ExitType'] => Enum['main', 'cgroup'], Optional['RemainAfterExit'] => Boolean,