Skip to content

Commit ffc54a4

Browse files
committed
Allow LimitCORE in [Service] for manage_unit/dropin
Addition of LimitCOR to `[service]` section of `systemd::manage_unit` and `systemd::manage_dropin` Added as penance for giving a wrong guess twice to someone how to do this. Always confuse me since while: `systemctl show sshd.service -t LimitCORESoft` has a value it cannot be set as I understand it. * https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Process%20Properties
1 parent e6826fa commit ffc54a4

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

REFERENCE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,18 @@ systemd::manage_dropin { 'triggerlimit.conf':
794794
}
795795
```
796796

797+
##### drop in file to override the LimitCORE for a service
798+
799+
```puppet
800+
systemd::manage_dropin { 'corelimit.conf':
801+
ensure => present,
802+
unit => 'rsyslog.conf',
803+
path_entry => {
804+
'LimitCORE' => 'infinity',
805+
},
806+
}
807+
```
808+
797809
#### Parameters
798810

799811
The following parameters are available in the `systemd::manage_dropin` defined type:
@@ -2259,6 +2271,7 @@ Struct[{
22592271
Optional['KillSignal'] => Pattern[/^SIG[A-Z]+$/],
22602272
Optional['KillMode'] => Enum['control-group', 'mixed', 'process', 'none'],
22612273
Optional['SyslogIdentifier'] => String,
2274+
Optional['LimitCORE'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'],
22622275
Optional['RestartSec'] => String,
22632276
Optional['TimeoutStartSec'] => String,
22642277
Optional['TimeoutStopSec'] => String,

manifests/manage_dropin.pp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# },
1515
# }
1616
#
17-
## @example drop in file to change a path unit and override TriggerLimitBurst
17+
# @example drop in file to change a path unit and override TriggerLimitBurst
1818
# systemd::manage_dropin { 'triggerlimit.conf':
1919
# ensure => present,
2020
# unit => 'passwd.path',
@@ -23,6 +23,15 @@
2323
# },
2424
# }
2525
#
26+
# @example drop in file to override the LimitCORE for a service
27+
# systemd::manage_dropin { 'corelimit.conf':
28+
# ensure => present,
29+
# unit => 'rsyslog.conf',
30+
# path_entry => {
31+
# 'LimitCORE' => 'infinity',
32+
# },
33+
# }
34+
#
2635
# @param unit The unit to create a dropfile for
2736
# @param filename The target unit file to create. The filename of the drop in. The full path is determined using the path, unit and this filename.
2837
# @param ensure The state of this dropin file

spec/defines/manage_dropin_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
DefaultDependencies: true
2525
},
2626
service_entry: {
27-
SyslogIdentifier: 'simple'
27+
SyslogIdentifier: 'simple',
28+
LimitCORE: 'infinity',
2829
}
2930
)
3031
end
3132

3233
it {
3334
is_expected.to contain_systemd__dropin_file('foobar.conf').
35+
with_content(%r{^LimitCORE=infinity$}).
3436
with_content(%r{^DefaultDependencies=true$}).
3537
with_content(%r{^SyslogIdentifier=simple$})
3638
}

spec/type_aliases/systemd_unit_service_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
it { is_expected.to allow_value({ 'KillSignal' => 'SIGTERM' }) }
2828
it { is_expected.not_to allow_value({ 'KillSignal' => 'SIGterm' }) }
2929
it { is_expected.not_to allow_value({ 'KillSignal' => 9 }) }
30+
it { is_expected.to allow_value({ 'LimitCORE' => 'infinity' }) }
31+
it { is_expected.to allow_value({ 'LimitCORE' => '100M' }) }
32+
it { is_expected.not_to allow_value({ 'LimitCORE' => 'random string' }) }
3033

3134
it { is_expected.to allow_value({ 'ExecStart' => 'notabsolute.sh' }) }
3235
it { is_expected.not_to allow_value({ 'ExecStart' => '*/wrongprefix.sh' }) }

types/unit/service.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
Optional['KillSignal'] => Pattern[/^SIG[A-Z]+$/],
2424
Optional['KillMode'] => Enum['control-group', 'mixed', 'process', 'none'],
2525
Optional['SyslogIdentifier'] => String,
26+
Optional['LimitCORE'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'],
2627
Optional['RestartSec'] => String,
2728
Optional['TimeoutStartSec'] => String,
2829
Optional['TimeoutStopSec'] => String,

0 commit comments

Comments
 (0)