diff --git a/manifests/init.pp b/manifests/init.pp index 832ff4d..7be8738 100755 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -152,7 +152,8 @@ $refresh = $uchiwa::params::refresh, $sensu_api_endpoints = $uchiwa::params::sensu_api_endpoints, $users = $uchiwa::params::users, - $auth = $uchiwa::params::auth + $auth = $uchiwa::params::auth, + $log_level = $uchiwa::params::log_level ) inherits uchiwa::params { # validate parameters here @@ -175,6 +176,7 @@ validate_array($sensu_api_endpoints) validate_array($users) validate_hash($auth) + validate_re($log_level, 'trace|debug|info|warn|fatal') anchor { 'uchiwa::begin': } -> class { 'uchiwa::install': } -> diff --git a/manifests/params.pp b/manifests/params.pp index f978951..24d30c4 100755 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -27,6 +27,7 @@ $manage_services = true $manage_package = true $manage_user = true + $log_level = 'info' $sensu_api_endpoints = [ { diff --git a/spec/classes/uchiwa_spec.rb b/spec/classes/uchiwa_spec.rb index c180f7b..212eca5 100644 --- a/spec/classes/uchiwa_spec.rb +++ b/spec/classes/uchiwa_spec.rb @@ -178,4 +178,12 @@ } end + context 'with debug log level' do + let(:params) {{ :log_level => 'debug' }} + it { + should contain_file('/etc/sensu/uchiwa.json') \ + .with_content(/"loglevel": "debug"/) + } + end + end diff --git a/templates/etc/sensu/uchiwa.json.erb b/templates/etc/sensu/uchiwa.json.erb index 9b8a1d0..bb0f1d4 100644 --- a/templates/etc/sensu/uchiwa.json.erb +++ b/templates/etc/sensu/uchiwa.json.erb @@ -27,6 +27,7 @@ "uchiwa": { "host": "<%= @host %>", "port": <%= @port %>, + "loglevel": "<%= @log_level %>", "user": "<%= @user %>", "pass": "<%= @pass %>", "refresh": <%= @refresh %><%= ',' if @users.size > 0 or @auth.size == 2 %>