Skip to content

Commit

Permalink
add configurable service name
Browse files Browse the repository at this point in the history
  • Loading branch information
Barhob authored and Jason Staph committed Sep 23, 2014
1 parent 58d5c11 commit 588d55a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
$nx_configtest_enable = false
$nx_service_restart = '/etc/init.d/nginx configtest && /etc/init.d/nginx restart'
$nx_service_ensure = running
$nx_service_name = 'nginx'

$nx_mail = false

Expand Down
2 changes: 2 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
$configtest_enable = $nginx::configtest_enable,
$service_restart = $nginx::service_restart,
$service_ensure = $nginx::service_ensure,
$service_name = 'nginx',
) {

$service_enable = $service_ensure ? {
Expand All @@ -34,6 +35,7 @@
}

service { 'nginx':
name => $service_name,
ensure => $service_ensure_real,
enable => $service_enable,
hasstatus => true,
Expand Down
17 changes: 13 additions & 4 deletions spec/classes/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
:configtest_enable => false,
:service_restart => '/etc/init.d/nginx configtest && /etc/init.d/nginx restart',
:service_ensure => 'running',
:service_name => 'nginx',
} end

context "using default parameters" do

it { is_expected.to contain_service('nginx').with(
:ensure => 'running',
:enable => true,
:hasstatus => true,
:hasrestart => true
:ensure => 'running',
:enable => true,
:hasstatus => true,
:hasrestart => true,
)}

it { is_expected.to contain_service('nginx').without_restart }
Expand All @@ -30,6 +31,7 @@
:configtest_enable => true,
:service_restart => '/etc/init.d/nginx configtest && /etc/init.d/nginx restart',
:service_ensure => 'running',
:service_name => 'nginx',
} end
it { is_expected.to contain_service('nginx').with_restart('/etc/init.d/nginx configtest && /etc/init.d/nginx restart') }

Expand All @@ -38,9 +40,16 @@
:configtest_enable => true,
: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
end

describe "when service_name => 'nginx14" do
let :params do {
:service_name => 'nginx14',
} end
it { is_expected.to contain_service('nginx').with_name('nginx14') }
end
end

0 comments on commit 588d55a

Please sign in to comment.