diff --git a/manifests/server.pp b/manifests/server.pp index 8bcf9e8..b900142 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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,12 +41,13 @@ class mysql::server ( $service_ensure = 'stopped' } - service { 'mysqld': - ensure => $service_ensure, - name => $service_name, - enable => $enabled, - require => Package['mysql-server'], - provider => $service_provider, + if $manage_service { + service { 'mysqld': + ensure => $service_ensure, + name => $service_name, + enable => $enabled, + require => Package['mysql-server'], + provider => $service_provider, + } } - } diff --git a/spec/classes/mysql_server_spec.rb b/spec/classes/mysql_server_spec.rb index e4d6c5d..8da66a7 100644 --- a/spec/classes/mysql_server_spec.rb +++ b/spec/classes/mysql_server_spec.rb @@ -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( - :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 } + 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]' + ).without_provider + else + should_not contain_service('mysqld') + end + } end end end