]> review.fuel-infra Code Review - puppet-modules/puppet-ceilometer.git/commitdiff
Allow log_dir to be set to false in order to disable file logging
authorDavid Moreau Simard <dmsimard@iweb.com>
Fri, 14 Feb 2014 16:42:16 +0000 (11:42 -0500)
committerDavid Moreau Simard <dmsimard@iweb.com>
Fri, 14 Feb 2014 16:47:19 +0000 (11:47 -0500)
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

manifests/init.pp
spec/classes/ceilometer_init_spec.rb

index 20b83df92bba39762e4e5b7025843c4564e722ed..b6d7088cd6dd7f3af54ecda1792e13bbf65cf4eb 100644 (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 {
index 7fcaa70a3d36dc832e25230741b4a150c2e8ec97..5906da2d0b387223d1291bcc8fb278d1617990ca 100644 (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