Skip to content

Commit

Permalink
Remove unnecessary class parameters from nginx::service
Browse files Browse the repository at this point in the history
Class `nginx::service` is private, declared once and should reference
variables only from the main class.
  • Loading branch information
Taylan Develioglu committed Apr 24, 2018
1 parent 6103b40 commit 8f3c667
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,36 @@
# Sample Usage:
#
# This class file is not called directly
class nginx::service(
$service_restart = $::nginx::service_restart,
$service_ensure = $::nginx::service_ensure,
$service_name = $::nginx::service_name,
$service_flags = $::nginx::service_flags,
$service_manage = $::nginx::service_manage,
) {

class nginx::service {
assert_private()

$service_enable = $service_ensure ? {
$service_enable = $::nginx::service_ensure ? {
'running' => true,
'absent' => false,
'stopped' => false,
'undef' => undef,
default => true,
}

if $service_ensure == 'undef' {
if $::nginx::service_ensure == 'undef' {
$service_ensure_real = undef
} else {
$service_ensure_real = $service_ensure
$service_ensure_real = $::nginx::service_ensure
}

if $service_manage {
if $::nginx::service_manage {
case $facts['os']['name'] {
'OpenBSD': {
service { $service_name:
service { $::nginx::service_name:
ensure => $service_ensure_real,
enable => $service_enable,
flags => $service_flags,
flags => $::nginx::service_flags,
hasstatus => true,
hasrestart => true,
}
}
default: {
service { $service_name:
service { $::nginx::service_name:
ensure => $service_ensure_real,
enable => $service_enable,
hasstatus => true,
Expand All @@ -60,9 +53,9 @@
}

# Allow overriding of 'restart' of Service resource; not used by default
if $service_restart {
Service[$service_name] {
restart => $service_restart,
if $::nginx::service_restart {
Service[$::nginx::service_name] {
restart => $::nginx::service_restart,
}
}
}

0 comments on commit 8f3c667

Please sign in to comment.