From c1cb58f6f13de9cecf5be43ecc9d823e89d7f0c3 Mon Sep 17 00:00:00 2001 From: Barhob Date: Sun, 21 Sep 2014 21:13:53 -0400 Subject: [PATCH] add configurable service name --- manifests/service.pp | 2 ++ spec/classes/service_spec.rb | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/manifests/service.pp b/manifests/service.pp index 17616f5..fa7fedc 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -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, diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb index f737b55..77deb63 100644 --- a/spec/classes/service_spec.rb +++ b/spec/classes/service_spec.rb @@ -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