Skip to content

Commit

Permalink
Allow log_dir to be set to false in order to disable file logging
Browse files Browse the repository at this point in the history
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
(cherry picked from commit 2b35c1a)
  • Loading branch information
David Moreau Simard committed Feb 14, 2014
1 parent 0a6d87c commit f3f9199
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
19 changes: 14 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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*]
Expand Down Expand Up @@ -175,19 +175,28 @@
}

# Once we got here, we can act as an honey badger on the rpc used.

ceilometer_config {
'DEFAULT/rpc_backend' : value => $rpc_backend;
'DEFAULT/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/
'DEFAULT/glance_control_exchange': value => 'glance';
'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 {
Expand Down
13 changes: 11 additions & 2 deletions spec/classes/ceilometer_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,21 @@
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
Expand Down

0 comments on commit f3f9199

Please sign in to comment.