Skip to content

Commit 27a5103

Browse files
committed
Unit_file: Add notify_service
1 parent ae5dfe5 commit 27a5103

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

manifests/unit_file.pp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
# @param daemon_reload
6565
# call `systemd::daemon-reload` to ensure that the modified unit file is loaded
6666
#
67+
# @param notify_service
68+
# Notify service if systemd file is changed
69+
#
6770
# @example manage unit file + service
6871
# systemd::unit_file { 'foo.service':
6972
# content => file("${module_name}/foo.service"),
@@ -88,7 +91,8 @@
8891
Optional[Boolean] $hasstatus = undef,
8992
Boolean $selinux_ignore_defaults = false,
9093
Hash[String[1], Any] $service_parameters = {},
91-
Boolean $daemon_reload = true
94+
Boolean $daemon_reload = true,
95+
Boolean $notify_service = true,
9296
) {
9397
include systemd
9498

@@ -152,7 +156,9 @@
152156
}
153157
Service[$name] -> File["${path}/${name}"]
154158
} else {
155-
File["${path}/${name}"] ~> Service[$name]
159+
if $notify_service {
160+
File["${path}/${name}"] ~> Service[$name]
161+
}
156162

157163
if $daemon_reload {
158164
Systemd::Daemon_reload[$name] ~> Service[$name]

spec/defines/unit_file_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,16 @@
267267
expect(subject).not_to create_systemd__daemon_reload(title)
268268
}
269269
end
270+
271+
context 'notify_service => false' do
272+
let(:params) { { enable: true, notify_service: false } }
273+
274+
it do
275+
is_expected.not_to contain_service(title).with_subscribes_to(
276+
"File[/etc/systemd/system/#{title}]"
277+
)
278+
end
279+
end
270280
end
271281
end
272282
end

0 commit comments

Comments
 (0)