Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable service name #534

Merged
merged 2 commits into from
Dec 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
$configtest_enable = false,
$service_ensure = running,
$service_restart = '/etc/init.d/nginx configtest && /etc/init.d/nginx restart',
$service_name = undef,
### END Service Configuration ###

### START Hiera Lookups ###
Expand Down Expand Up @@ -289,6 +290,7 @@
configtest_enable => $configtest_enable,
service_ensure => $service_ensure,
service_restart => $service_restart,
service_name => $service_name,
}

create_resources('::nginx::resource::upstream', $nginx_upstreams)
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 @@ -35,6 +36,7 @@

service { 'nginx':
ensure => $service_ensure_real,
name => $service_name,
enable => $service_enable,
hasstatus => true,
hasrestart => true,
Expand Down
9 changes: 9 additions & 0 deletions spec/classes/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
: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
Expand All @@ -25,6 +26,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 @@ -33,9 +35,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