Skip to content

Commit

Permalink
Restore $service_restart, but now without $configtest_enable paramete…
Browse files Browse the repository at this point in the history
…r (see comments in voxpupuli#921). Pass on $nginx::service_foo directly to service class
  • Loading branch information
William Yardley authored and Oleksandr Moskalenko committed Oct 17, 2016
1 parent c3158c2 commit 791400c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
11 changes: 4 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
### START Service Configuation ###
$service_ensure = running,
$service_flags = undef,
$service_restart = undef,
$service_name = undef,
$service_manage = true,
### END Service Configuration ###
Expand Down Expand Up @@ -300,14 +301,10 @@
sites_available_mode => $sites_available_mode,
}
}
Class['::nginx::package'] -> Class['::nginx::config'] ~> Class['::nginx::service']

class { '::nginx::service':
service_ensure => $service_ensure,
service_name => $service_name,
service_flags => $service_flags,
service_manage => $service_manage,
}
include '::nginx::service'

Class['::nginx::package'] -> Class['::nginx::config'] ~> Class['::nginx::service']

create_resources('nginx::resource::upstream', $nginx_upstreams)
create_resources('nginx::resource::vhost', $nginx_vhosts, $nginx_vhosts_defaults)
Expand Down
17 changes: 12 additions & 5 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
#
# This class file is not called directly
class nginx::service(
$service_ensure = 'running',
$service_name = 'nginx',
$service_flags = undef,
$service_manage = true,
) {
$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,
) inherits nginx {

$service_enable = $service_ensure ? {
'running' => true,
Expand Down Expand Up @@ -58,4 +59,10 @@
}
}

# Allow overriding of 'restart' of Service resource; not used by default
if $service_restart {
Service['nginx'] {
restart => $service_restart,
}
}
}
11 changes: 11 additions & 0 deletions spec/classes/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
it { is_expected.to contain_service('nginx').without_restart }
end

context "when service_restart => 'a restart command'" do
let :params do
{
service_restart: 'a restart command',
service_ensure: 'running',
service_name: 'nginx'
}
end
it { is_expected.to contain_service('nginx').with_restart('a restart command') }
end

describe "when service_name => 'nginx14" do
let :params do
{
Expand Down

0 comments on commit 791400c

Please sign in to comment.