Add service_manage parameter
This commit is contained in:
parent
a4cee014be
commit
446a3e9dcf
3 changed files with 30 additions and 17 deletions
|
@ -112,6 +112,7 @@ class nginx (
|
||||||
$service_flags = undef,
|
$service_flags = undef,
|
||||||
$service_restart = '/etc/init.d/nginx reload',
|
$service_restart = '/etc/init.d/nginx reload',
|
||||||
$service_name = undef,
|
$service_name = undef,
|
||||||
|
$service_manage = true,
|
||||||
### END Service Configuration ###
|
### END Service Configuration ###
|
||||||
|
|
||||||
### START Hiera Lookups ###
|
### START Hiera Lookups ###
|
||||||
|
@ -294,6 +295,7 @@ class nginx (
|
||||||
service_restart => $service_restart,
|
service_restart => $service_restart,
|
||||||
service_name => $service_name,
|
service_name => $service_name,
|
||||||
service_flags => $service_flags,
|
service_flags => $service_flags,
|
||||||
|
service_manage => $service_manage,
|
||||||
}
|
}
|
||||||
|
|
||||||
create_resources('nginx::resource::upstream', $nginx_upstreams)
|
create_resources('nginx::resource::upstream', $nginx_upstreams)
|
||||||
|
|
|
@ -19,6 +19,7 @@ class nginx::service(
|
||||||
$service_ensure = $::nginx::service_ensure,
|
$service_ensure = $::nginx::service_ensure,
|
||||||
$service_name = 'nginx',
|
$service_name = 'nginx',
|
||||||
$service_flags = undef,
|
$service_flags = undef,
|
||||||
|
$service_manage = true,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$service_enable = $service_ensure ? {
|
$service_enable = $service_ensure ? {
|
||||||
|
@ -35,24 +36,26 @@ class nginx::service(
|
||||||
$service_ensure_real = $service_ensure
|
$service_ensure_real = $service_ensure
|
||||||
}
|
}
|
||||||
|
|
||||||
case $::osfamily {
|
if $service_manage {
|
||||||
'OpenBSD': {
|
case $::osfamily {
|
||||||
service { 'nginx':
|
'OpenBSD': {
|
||||||
ensure => $service_ensure_real,
|
service { 'nginx':
|
||||||
name => $service_name,
|
ensure => $service_ensure_real,
|
||||||
enable => $service_enable,
|
name => $service_name,
|
||||||
flags => $service_flags,
|
enable => $service_enable,
|
||||||
hasstatus => true,
|
flags => $service_flags,
|
||||||
hasrestart => true,
|
hasstatus => true,
|
||||||
|
hasrestart => true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
default: {
|
||||||
default: {
|
service { 'nginx':
|
||||||
service { 'nginx':
|
ensure => $service_ensure_real,
|
||||||
ensure => $service_ensure_real,
|
name => $service_name,
|
||||||
name => $service_name,
|
enable => $service_enable,
|
||||||
enable => $service_enable,
|
hasstatus => true,
|
||||||
hasstatus => true,
|
hasrestart => true,
|
||||||
hasrestart => true,
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ describe 'nginx::service' do
|
||||||
:service_restart => '/etc/init.d/nginx reload',
|
:service_restart => '/etc/init.d/nginx reload',
|
||||||
:service_ensure => 'running',
|
:service_ensure => 'running',
|
||||||
:service_name => 'nginx',
|
:service_name => 'nginx',
|
||||||
|
:service_manage => true,
|
||||||
} end
|
} end
|
||||||
|
|
||||||
context "using default parameters" do
|
context "using default parameters" do
|
||||||
|
@ -47,4 +48,11 @@ describe 'nginx::service' do
|
||||||
} end
|
} end
|
||||||
it { is_expected.to contain_service('nginx').with_name('nginx14') }
|
it { is_expected.to contain_service('nginx').with_name('nginx14') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "when service_manage => false" do
|
||||||
|
let :params do {
|
||||||
|
:service_manage => false,
|
||||||
|
} end
|
||||||
|
it { is_expected.not_to contain_service('nginx') }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue