Merge pull request #122 from hunner/optional_service
Optionally manage the mysqld service
This commit is contained in:
commit
c84ffdeef0
2 changed files with 26 additions and 18 deletions
|
@ -20,7 +20,8 @@ class mysql::server (
|
|||
$service_name = $mysql::params::service_name,
|
||||
$service_provider = $mysql::params::service_provider,
|
||||
$config_hash = {},
|
||||
$enabled = true
|
||||
$enabled = true,
|
||||
$manage_service = true
|
||||
) inherits mysql::params {
|
||||
|
||||
Class['mysql::server'] -> Class['mysql::config']
|
||||
|
@ -40,6 +41,7 @@ class mysql::server (
|
|||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
service { 'mysqld':
|
||||
ensure => $service_ensure,
|
||||
name => $service_name,
|
||||
|
@ -47,5 +49,5 @@ class mysql::server (
|
|||
require => Package['mysql-server'],
|
||||
provider => $service_provider,
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ describe 'mysql::server' do
|
|||
let :constant_parameter_defaults do
|
||||
{:config_hash => {},
|
||||
:package_ensure => 'present',
|
||||
:enabled => true
|
||||
:enabled => true,
|
||||
:manage_service => true
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -53,7 +54,8 @@ describe 'mysql::server' do
|
|||
:package_ensure => 'latest',
|
||||
:service_name => 'dans_service',
|
||||
:config_hash => {'root_password' => 'foo'},
|
||||
:enabled => false
|
||||
:enabled => false,
|
||||
:manage_service => false
|
||||
}
|
||||
].each do |passed_params|
|
||||
|
||||
|
@ -76,14 +78,18 @@ describe 'mysql::server' do
|
|||
:ensure => param_values[:package_ensure]
|
||||
)}
|
||||
|
||||
it { should contain_service('mysqld').with(
|
||||
it {
|
||||
if param_values[:manage_service]
|
||||
should contain_service('mysqld').with(
|
||||
:name => param_values[:service_name],
|
||||
:ensure => param_values[:enabled] ? 'running' : 'stopped',
|
||||
:enable => param_values[:enabled],
|
||||
:require => 'Package[mysql-server]'
|
||||
)}
|
||||
|
||||
it { should contain_service('mysqld').without_provider }
|
||||
).without_provider
|
||||
else
|
||||
should_not contain_service('mysqld')
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue