Skip to content

Commit 49f5b89

Browse files
committed
Simplify service class
It's valid to pass in undef values. That makes the OpenBSD check redundant. The same goes for the restart command. That removes pretty much all logic so there is no more benefit to having class parameters. That's why it now uses all the variables directly from the nginx class. The has{status,restart} parameters default to true since Puppet 2.7 so can be removed.
1 parent f042e75 commit 49f5b89

File tree

2 files changed

+10
-50
lines changed

2 files changed

+10
-50
lines changed

manifests/init.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
### END Package Configuration ###
200200

201201
### START Service Configuation ###
202-
$service_ensure = running,
202+
Stdlib::Ensure::Service $service_ensure = 'running',
203203
$service_enable = true,
204204
$service_flags = undef,
205205
$service_restart = undef,

manifests/service.pp

+9-49
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,14 @@
1-
# Class: nginx::service
2-
#
3-
# This module manages NGINX service management and server rebuild
4-
#
5-
# Parameters:
6-
#
7-
# There are no default parameters for this class.
8-
#
9-
# Actions:
10-
#
11-
# Requires:
12-
#
13-
# Sample Usage:
14-
#
15-
# This class file is not called directly
16-
class nginx::service (
17-
$service_restart = $nginx::service_restart,
18-
$service_ensure = $nginx::service_ensure,
19-
$service_enable = $nginx::service_enable,
20-
$service_name = $nginx::service_name,
21-
$service_flags = $nginx::service_flags,
22-
$service_manage = $nginx::service_manage,
23-
) {
1+
# @summary Manage NGINX service management
2+
# @api private
3+
class nginx::service {
244
assert_private()
255

26-
if $service_manage {
27-
case $facts['os']['name'] {
28-
'OpenBSD': {
29-
service { $service_name:
30-
ensure => $service_ensure,
31-
enable => $service_enable,
32-
flags => $service_flags,
33-
hasstatus => true,
34-
hasrestart => true,
35-
}
36-
}
37-
default: {
38-
service { $service_name:
39-
ensure => $service_ensure,
40-
enable => $service_enable,
41-
hasstatus => true,
42-
hasrestart => true,
43-
}
44-
}
45-
}
46-
}
47-
48-
# Allow overriding of 'restart' of Service resource; not used by default
49-
if $service_restart {
50-
Service[$service_name] {
51-
restart => $service_restart,
6+
if $nginx::service_manage {
7+
service { $nginx::service_name:
8+
ensure => $nginx::service_ensure,
9+
enable => $nginx::service_enable,
10+
flags => $nginx::service_flags,
11+
restart => $nginx::service_restart,
5212
}
5313
}
5414
}

0 commit comments

Comments
 (0)