diff --git a/manifests/init.pp b/manifests/init.pp index 08350ed0c..96b5c29b9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,6 +4,7 @@ # class memcached ( $package_ensure = 'present', + $service_manage = true, $logfile = $::memcached::params::logfile, $pidfile = '/var/run/memcached.pid', $manage_firewall = false, @@ -35,6 +36,7 @@ } validate_bool($manage_firewall_bool) validate_bool($service_restart) + validate_bool($service_manage) if $package_ensure == 'absent' { $service_ensure = 'stopped' @@ -70,7 +72,7 @@ } } - if $service_restart { + if $service_restart and $service_manage { $service_notify_real = Service[$memcached::params::service_name] } else { $service_notify_real = undef @@ -87,11 +89,13 @@ } } - service { $memcached::params::service_name: - ensure => $service_ensure, - enable => $service_enable, - hasrestart => true, - hasstatus => $memcached::params::service_hasstatus, + if $service_manage { + service { $memcached::params::service_name: + ensure => $service_ensure, + enable => $service_enable, + hasrestart => true, + hasstatus => $memcached::params::service_hasstatus, + } } if $use_registry { @@ -99,7 +103,7 @@ ensure => 'present', type => 'string', data => template($memcached::params::config_tmpl), - notify => Service[$memcached::params::service_name] + notify => $service_notify_real, } } } diff --git a/spec/classes/memcached_spec.rb b/spec/classes/memcached_spec.rb index 3357569f7..c2a836da4 100644 --- a/spec/classes/memcached_spec.rb +++ b/spec/classes/memcached_spec.rb @@ -105,6 +105,9 @@ { :package_ensure => 'absent', :install_dev => true + }, + { + :service_manage => false } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do @@ -148,7 +151,9 @@ )} it { - if param_hash[:package_ensure] == 'absent' + if param_hash[:service_manage] == false + should_not contain_service('memcached') + elsif param_hash[:package_ensure] == 'absent' should contain_service("memcached").with( 'ensure' => 'stopped', 'enable' => false