Allow log_dir to be set to false in order to disable file logging

This backward compatible commit allows a user to disable logging to
a directory for example if using syslog logging.

Change-Id: I8b496c311b9f26cab64c38d1cfd545784dfc7cab
Related-bug: #1269482
This commit is contained in:
David Moreau Simard 2014-02-14 11:42:16 -05:00
parent 499670d585
commit 2b35c1a04c
2 changed files with 25 additions and 7 deletions

View File

@ -11,6 +11,7 @@
# should the daemons log debug messages. Optional. Defaults to 'False'
# [*log_dir*]
# (optional) directory to which ceilometer logs are sent.
# If set to boolean false, it will not log to any directory.
# Defaults to '/var/log/ceilometer'
# [*verbose*]
# should the daemons log verbose messages. Optional. Defaults to 'False'
@ -21,9 +22,8 @@
# (optional) Syslog facility to receive log lines.
# Defaults to 'LOG_USER'
# [*rpc_backend*]
# (optional) what rpc/queuing service to use
# Defaults to impl_kombu (rabbitmq)
#
# (optional) what rpc/queuing service to use
# Defaults to impl_kombu (rabbitmq)
# [*rabbit_host*]
# ip or hostname of the rabbit server. Optional. Defaults to '127.0.0.1'
# [*rabbit_port*]
@ -175,12 +175,10 @@ class ceilometer(
}
# Once we got here, we can act as an honey badger on the rpc used.
ceilometer_config {
'DEFAULT/rpc_backend' : value => $rpc_backend;
'publisher/metering_secret' : value => $metering_secret;
'DEFAULT/debug' : value => $debug;
'DEFAULT/log_dir' : value => $log_dir;
'DEFAULT/verbose' : value => $verbose;
# Fix a bad default value in ceilometer.
# Fixed in https://review.openstack.org/#/c/18487/
@ -188,6 +186,17 @@ class ceilometer(
'DEFAULT/notification_topics' : value => 'notifications';
}
# Log configuration
if $log_dir {
ceilometer_config {
'DEFAULT/log_dir' : value => $log_dir;
}
} else {
ceilometer_config {
'DEFAULT/log_dir' : ensure => absent;
}
}
# Syslog configuration
if $use_syslog {
ceilometer_config {

View File

@ -117,12 +117,21 @@ describe 'ceilometer' do
it { expect { should raise_error(Puppet::Error) } }
end
it 'configures logging, debug and verbosity' do
it 'configures debug and verbosity' do
should contain_ceilometer_config('DEFAULT/debug').with_value( params[:debug] )
should contain_ceilometer_config('DEFAULT/log_dir').with_value( params[:log_dir] )
should contain_ceilometer_config('DEFAULT/verbose').with_value( params[:verbose] )
end
it 'configures logging directory by default' do
should contain_ceilometer_config('DEFAULT/log_dir').with_value( params[:log_dir] )
end
context 'with logging directory disabled' do
before { params.merge!( :log_dir => false) }
it { should contain_ceilometer_config('DEFAULT/log_dir').with_ensure('absent') }
end
it 'configures syslog to be disabled by default' do
should contain_ceilometer_config('DEFAULT/use_syslog').with_value('false')
end