add configurable service name

This commit is contained in:
Barhob 2014-09-21 21:13:53 -04:00 committed by Matthew Haughton
parent 9e8290e739
commit c1cb58f6f1
2 changed files with 11 additions and 0 deletions

View file

@ -17,6 +17,7 @@ class nginx::service(
$configtest_enable = $::nginx::configtest_enable,
$service_restart = $::nginx::service_restart,
$service_ensure = $::nginx::service_ensure,
$service_name = 'nginx',
) {
$service_enable = $service_ensure ? {
@ -35,6 +36,7 @@ class nginx::service(
service { 'nginx':
ensure => $service_ensure_real,
name => $service_name,
enable => $service_enable,
hasstatus => true,
hasrestart => true,

View file

@ -5,6 +5,7 @@ describe 'nginx::service' do
: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
@ -25,6 +26,7 @@ describe 'nginx::service' do
: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') }
@ -33,9 +35,16 @@ describe 'nginx::service' do
: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