Skip to content

Commit

Permalink
Allow WorkingDirectory to be specified in [Service]
Browse files Browse the repository at this point in the history
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
  • Loading branch information
traylenator committed Jun 15, 2023
1 parent e3f8e0c commit 9554fde
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions REFERENCE.md
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions spec/type_aliases/systemd_unit_service_spec.rb
Expand Up @@ -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' => '' }) }

Check failure on line 47 in spec/type_aliases/systemd_unit_service_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body end. (https://rubystyle.guide#empty-lines-around-bodies)
end
1 change: 1 addition & 0 deletions types/unit/service.pp
Expand Up @@ -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,
Expand Down

0 comments on commit 9554fde

Please sign in to comment.