Skip to content

Commit 35e2f36

Browse files
committed
Remove restart_service on service_limits define
Since 97dd16f this parameter is a bad idea. It doesn't do a daemon reload and it may restart at the wrong time. In fact, I'd argue it's always been a bad idea. The recommended alternative to this is to manage the service explicitly and let Puppet handle it. There is an automatic notify that takes care of it. Fixes voxpupuli#190
1 parent 40a0f77 commit 35e2f36

File tree

3 files changed

+16
-37
lines changed

3 files changed

+16
-37
lines changed

REFERENCE.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,6 @@ The following parameters are available in the `systemd::service_limits` defined
12731273
* [`selinux_ignore_defaults`](#-systemd--service_limits--selinux_ignore_defaults)
12741274
* [`limits`](#-systemd--service_limits--limits)
12751275
* [`source`](#-systemd--service_limits--source)
1276-
* [`restart_service`](#-systemd--service_limits--restart_service)
12771276

12781277
##### <a name="-systemd--service_limits--name"></a>`name`
12791278

@@ -1325,14 +1324,6 @@ A ``File`` resource compatible ``source``
13251324

13261325
Default value: `undef`
13271326

1328-
##### <a name="-systemd--service_limits--restart_service"></a>`restart_service`
1329-
1330-
Data type: `Boolean`
1331-
1332-
Restart the managed service after setting the limits
1333-
1334-
Default value: `true`
1335-
13361327
### <a name="systemd--timer"></a>`systemd::timer`
13371328

13381329
Create a timer and optionally a service unit to execute with the timer unit

manifests/service_limits.pp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,12 @@
2626
#
2727
# * Mutually exclusive with ``$limits``
2828
#
29-
# @param restart_service
30-
# Restart the managed service after setting the limits
31-
#
3229
define systemd::service_limits (
3330
Enum['present', 'absent', 'file'] $ensure = 'present',
3431
Stdlib::Absolutepath $path = '/etc/systemd/system',
3532
Boolean $selinux_ignore_defaults = false,
3633
Optional[Systemd::ServiceLimits] $limits = undef,
3734
Optional[String] $source = undef,
38-
Boolean $restart_service = true
3935
) {
4036
include systemd
4137

@@ -67,15 +63,6 @@
6763
selinux_ignore_defaults => $selinux_ignore_defaults,
6864
content => $_content,
6965
source => $source,
70-
}
71-
72-
if $restart_service {
73-
exec { "restart ${name} because limits":
74-
command => "systemctl restart ${name}",
75-
path => $facts['path'],
76-
refreshonly => true,
77-
}
78-
79-
Systemd::Dropin_file["${name}-90-limits.conf"] ~> Exec["restart ${name} because limits"]
66+
notify_service => true,
8067
}
8168
}

spec/defines/service_limits_spec.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,20 @@
5151
with_content(%r{IOReadBandwidthMax=/bw/max 10K})
5252
}
5353

54-
it {
55-
expect(subject).to create_exec("restart #{title} because limits").with(
56-
command: "systemctl restart #{title}",
57-
refreshonly: true
58-
)
59-
}
54+
describe 'with service managed' do
55+
let(:pre_condition) do
56+
<<-PUPPET
57+
service { 'test':
58+
}
59+
PUPPET
60+
end
61+
62+
it { is_expected.to compile.with_all_deps }
63+
it do
64+
is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").
65+
that_notifies('Service[test]')
66+
end
67+
end
6068
end
6169

6270
describe 'ensured absent' do
@@ -66,14 +74,7 @@
6674

6775
it do
6876
expect(subject).to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").
69-
with_ensure('absent').
70-
that_notifies("Exec[restart #{title} because limits]")
71-
end
72-
73-
it do
74-
expect(subject).to create_exec("restart #{title} because limits").
75-
with_command("systemctl restart #{title}").
76-
with_refreshonly(true)
77+
with_ensure('absent')
7778
end
7879
end
7980
end

0 commit comments

Comments
 (0)