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

Add manage_service parameter #817

Merged
merged 1 commit into from
Jun 23, 2016
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 @@ -112,6 +112,7 @@
$service_flags = undef,
$service_restart = '/etc/init.d/nginx reload',
$service_name = undef,
$service_manage = true,
### END Service Configuration ###

### START Hiera Lookups ###
Expand Down Expand Up @@ -294,6 +295,7 @@
service_restart => $service_restart,
service_name => $service_name,
service_flags => $service_flags,
service_manage => $service_manage,
}

create_resources('nginx::resource::upstream', $nginx_upstreams)
Expand Down
37 changes: 20 additions & 17 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$service_ensure = $::nginx::service_ensure,
$service_name = 'nginx',
$service_flags = undef,
$service_manage = true,
) {

$service_enable = $service_ensure ? {
Expand All @@ -35,24 +36,26 @@
$service_ensure_real = $service_ensure
}

case $::osfamily {
'OpenBSD': {
service { 'nginx':
ensure => $service_ensure_real,
name => $service_name,
enable => $service_enable,
flags => $service_flags,
hasstatus => true,
hasrestart => true,
if $service_manage {
case $::osfamily {
'OpenBSD': {
service { 'nginx':
ensure => $service_ensure_real,
name => $service_name,
enable => $service_enable,
flags => $service_flags,
hasstatus => true,
hasrestart => true,
}
}
}
default: {
service { 'nginx':
ensure => $service_ensure_real,
name => $service_name,
enable => $service_enable,
hasstatus => true,
hasrestart => true,
default: {
service { 'nginx':
ensure => $service_ensure_real,
name => $service_name,
enable => $service_enable,
hasstatus => true,
hasrestart => true,
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions spec/classes/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:service_restart => '/etc/init.d/nginx reload',
:service_ensure => 'running',
:service_name => 'nginx',
:service_manage => true,
} end

context "using default parameters" do
Expand Down Expand Up @@ -47,4 +48,11 @@
} end
it { is_expected.to contain_service('nginx').with_name('nginx14') }
end

describe "when service_manage => false" do
let :params do {
:service_manage => false,
} end
it { is_expected.not_to contain_service('nginx') }
end
end