Skip to content

Commit e6826fa

Browse files
authored
Merge pull request #339 from traylenator/syslogidentifier
Allow SyslogIdentifier, KillMode and KillSignal to [service] section
2 parents 3010628 + 245bb62 commit e6826fa

File tree

5 files changed

+34
-8
lines changed

5 files changed

+34
-8
lines changed

REFERENCE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,6 +2256,9 @@ Struct[{
22562256
Optional['ExecReload'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
22572257
Optional['ExecStop'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
22582258
Optional['ExecStopPost'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
2259+
Optional['KillSignal'] => Pattern[/^SIG[A-Z]+$/],
2260+
Optional['KillMode'] => Enum['control-group', 'mixed', 'process', 'none'],
2261+
Optional['SyslogIdentifier'] => String,
22592262
Optional['RestartSec'] => String,
22602263
Optional['TimeoutStartSec'] => String,
22612264
Optional['TimeoutStopSec'] => String,

spec/defines/manage_dropin_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@
2222
super().merge(
2323
unit_entry: {
2424
DefaultDependencies: true
25+
},
26+
service_entry: {
27+
SyslogIdentifier: 'simple'
2528
}
2629
)
2730
end
2831

2932
it {
3033
is_expected.to contain_systemd__dropin_file('foobar.conf').
31-
with_content(%r{^DefaultDependencies=true$})
34+
with_content(%r{^DefaultDependencies=true$}).
35+
with_content(%r{^SyslogIdentifier=simple$})
3236
}
3337
end
3438

spec/defines/manage_unit_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
DefaultDependencies: true,
1919
},
2020
service_entry: {
21-
Type: 'oneshot',
21+
Type: 'oneshot',
2222
ExecStart: '/usr/bin/doit.sh',
23+
SyslogIdentifier: 'doit-backwards.sh',
2324
},
2425
install_entry: {
2526
WantedBy: 'multi-user.target',
@@ -34,6 +35,7 @@
3435
with_content(%r{^\[Unit\]$}).
3536
with_content(%r{^DefaultDependencies=true$}).
3637
with_content(%r{^\[Service\]$}).
38+
with_content(%r{^SyslogIdentifier=doit-backwards\.sh$}).
3739
with_content(%r{^\[Install\]$}).
3840
with_content(%r{^Description=My great service$}).
3941
with_content(%r{^Description=has two lines of description$}).

spec/type_aliases/systemd_unit_service_spec.rb

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,29 @@
55
describe 'Systemd::Unit::Service' do
66
%w[ExecStart ExecStartPre ExecStartPost ExecCondition ExecReload ExecStop ExecStopPost].each do |depend|
77
context "with a key of #{depend} can have values of commands" do
8-
it { is_expected.to allow_value({ depend.to_s => '/usr/bin/doit.sh' }) }
9-
it { is_expected.to allow_value({ depend.to_s => ['/usr/bin/doit.sh'] }) }
10-
it { is_expected.to allow_value({ depend.to_s => ['-/usr/bin/doit.sh', ':/doit.sh', '+/doit.sh', '!/doit.sh', '!!/doit.sh'] }) }
11-
it { is_expected.to allow_value({ depend.to_s => '' }) }
12-
it { is_expected.to allow_value({ depend.to_s => [''] }) }
13-
it { is_expected.to allow_value({ depend.to_s => ['', '/doit.sh'] }) }
8+
it { is_expected.to allow_value({ depend => '/usr/bin/doit.sh' }) }
9+
it { is_expected.to allow_value({ depend => ['/usr/bin/doit.sh'] }) }
10+
it { is_expected.to allow_value({ depend => ['-/usr/bin/doit.sh', ':/doit.sh', '+/doit.sh', '!/doit.sh', '!!/doit.sh'] }) }
11+
it { is_expected.to allow_value({ depend => '' }) }
12+
it { is_expected.to allow_value({ depend => [''] }) }
13+
it { is_expected.to allow_value({ depend => ['', '/doit.sh'] }) }
1414
end
1515
end
1616

17+
%w[SyslogIdentifier].each do |depend|
18+
context "with a key of #{depend} can have values of strings" do
19+
it { is_expected.to allow_value({ depend => 'simple' }) }
20+
it { is_expected.not_to allow_value({ depend => ['', 'simple'] }) }
21+
end
22+
end
23+
24+
it { is_expected.to allow_value({ 'KillMode' => 'mixed' }) }
25+
it { is_expected.not_to allow_value({ 'KillMode' => 'wrong' }) }
26+
27+
it { is_expected.to allow_value({ 'KillSignal' => 'SIGTERM' }) }
28+
it { is_expected.not_to allow_value({ 'KillSignal' => 'SIGterm' }) }
29+
it { is_expected.not_to allow_value({ 'KillSignal' => 9 }) }
30+
1731
it { is_expected.to allow_value({ 'ExecStart' => 'notabsolute.sh' }) }
1832
it { is_expected.not_to allow_value({ 'ExecStart' => '*/wrongprefix.sh' }) }
1933

types/unit/service.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
Optional['ExecReload'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
2121
Optional['ExecStop'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
2222
Optional['ExecStopPost'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
23+
Optional['KillSignal'] => Pattern[/^SIG[A-Z]+$/],
24+
Optional['KillMode'] => Enum['control-group', 'mixed', 'process', 'none'],
25+
Optional['SyslogIdentifier'] => String,
2326
Optional['RestartSec'] => String,
2427
Optional['TimeoutStartSec'] => String,
2528
Optional['TimeoutStopSec'] => String,

0 commit comments

Comments
 (0)