diff --git a/manifests/init.pp b/manifests/init.pp index cc6703ec..74755eec 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,7 +12,12 @@ # [log_facility] # Syslog facility to receive log lines. # (Optional) Defaults to LOG_USER. - +# +# [*log_dir*] +# (optional) Directory where logs should be stored. +# If set to boolean false, it will not log to any directory. +# Defaults to '/var/log/cinder' +# class cinder ( $sql_connection, $sql_idle_timeout = '3600', @@ -42,6 +47,7 @@ class cinder ( $api_paste_config = '/etc/cinder/api-paste.ini', $use_syslog = false, $log_facility = 'LOG_USER', + $log_dir = '/var/log/cinder', $verbose = false, $debug = false ) { @@ -147,6 +153,16 @@ class cinder ( 'DEFAULT/rpc_backend': value => $rpc_backend; } + if $log_dir { + cinder_config { + 'DEFAULT/log_dir': value => $log_dir; + } + } else { + cinder_config { + 'DEFAULT/log_dir': ensure => absent; + } + } + if $use_syslog { cinder_config { 'DEFAULT/use_syslog': value => true; diff --git a/spec/classes/cinder_spec.rb b/spec/classes/cinder_spec.rb index d675e944..4754d7be 100644 --- a/spec/classes/cinder_spec.rb +++ b/spec/classes/cinder_spec.rb @@ -60,6 +60,7 @@ describe 'cinder' do should contain_cinder_config('DEFAULT/api_paste_config').with( :value => '/etc/cinder/api-paste.ini' ) + should contain_cinder_config('DEFAULT/log_dir').with(:value => '/var/log/cinder') end it { should contain_file('/etc/cinder/cinder.conf').with( @@ -207,4 +208,9 @@ describe 'cinder' do it { should contain_cinder_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') } end + describe 'with log_dir disabled' do + let(:params) { req_params.merge!({:log_dir => false}) } + it { should contain_cinder_config('DEFAULT/log_dir').with_ensure('absent') } + end + end