diff --git a/REFERENCE.md b/REFERENCE.md
index cff5ef1c..56004165 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -1273,7 +1273,6 @@ The following parameters are available in the `systemd::service_limits` defined
* [`selinux_ignore_defaults`](#-systemd--service_limits--selinux_ignore_defaults)
* [`limits`](#-systemd--service_limits--limits)
* [`source`](#-systemd--service_limits--source)
-* [`restart_service`](#-systemd--service_limits--restart_service)
##### `name`
@@ -1325,14 +1324,6 @@ A ``File`` resource compatible ``source``
Default value: `undef`
-##### `restart_service`
-
-Data type: `Boolean`
-
-Restart the managed service after setting the limits
-
-Default value: `true`
-
### `systemd::timer`
Create a timer and optionally a service unit to execute with the timer unit
diff --git a/manifests/service_limits.pp b/manifests/service_limits.pp
index 57ab142b..b8dfa77c 100644
--- a/manifests/service_limits.pp
+++ b/manifests/service_limits.pp
@@ -26,16 +26,12 @@
#
# * Mutually exclusive with ``$limits``
#
-# @param restart_service
-# Restart the managed service after setting the limits
-#
define systemd::service_limits (
Enum['present', 'absent', 'file'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/systemd/system',
Boolean $selinux_ignore_defaults = false,
Optional[Systemd::ServiceLimits] $limits = undef,
Optional[String] $source = undef,
- Boolean $restart_service = true
) {
include systemd
@@ -67,15 +63,6 @@
selinux_ignore_defaults => $selinux_ignore_defaults,
content => $_content,
source => $source,
- }
-
- if $restart_service {
- exec { "restart ${name} because limits":
- command => "systemctl restart ${name}",
- path => $facts['path'],
- refreshonly => true,
- }
-
- Systemd::Dropin_file["${name}-90-limits.conf"] ~> Exec["restart ${name} because limits"]
+ notify_service => true,
}
}
diff --git a/spec/defines/service_limits_spec.rb b/spec/defines/service_limits_spec.rb
index 9f580650..ed90f2da 100644
--- a/spec/defines/service_limits_spec.rb
+++ b/spec/defines/service_limits_spec.rb
@@ -51,12 +51,20 @@
with_content(%r{IOReadBandwidthMax=/bw/max 10K})
}
- it {
- expect(subject).to create_exec("restart #{title} because limits").with(
- command: "systemctl restart #{title}",
- refreshonly: true
- )
- }
+ describe 'with service managed' do
+ let(:pre_condition) do
+ <<-PUPPET
+ service { 'test':
+ }
+ PUPPET
+ end
+
+ it { is_expected.to compile.with_all_deps }
+ it do
+ is_expected.to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").
+ that_notifies('Service[test]')
+ end
+ end
end
describe 'ensured absent' do
@@ -66,14 +74,7 @@
it do
expect(subject).to create_file("/etc/systemd/system/#{title}.d/90-limits.conf").
- with_ensure('absent').
- that_notifies("Exec[restart #{title} because limits]")
- end
-
- it do
- expect(subject).to create_exec("restart #{title} because limits").
- with_command("systemctl restart #{title}").
- with_refreshonly(true)
+ with_ensure('absent')
end
end
end