From 0fd7ed9707d637ccf71cc12ad2d80cf03ed3c4ce Mon Sep 17 00:00:00 2001 From: Matthias Baur Date: Wed, 20 Sep 2017 11:32:18 +0200 Subject: [PATCH] Manage logging directory and file Fixes #172 --- manifests/config.pp | 10 ++++++++++ spec/classes/config_spec.rb | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/manifests/config.pp b/manifests/config.pp index 7184295f..95c3d0b7 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -18,6 +18,7 @@ $logging = $::icingaweb2::logging $logging_file = $::icingaweb2::logging_file + $logging_dir = dirname($::icingaweb2::logging_file) $logging_level = $::icingaweb2::logging_level $show_stacktraces = $::icingaweb2::show_stacktraces $module_path = $::icingaweb2::module_path @@ -51,6 +52,15 @@ path => $::path, } + file { $logging_dir: + ensure => directory, + mode => '0750', + } + file { $logging_file: + ensure => file, + mode => '0640', + } + icingaweb2::inisection {'logging': target => "${conf_dir}/config.ini", settings => { diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index a403800e..69a6e228 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -17,6 +17,14 @@ .with_settings({ 'show_stacktraces' => false, 'module_path' => '/usr/share/icingaweb2/modules', 'config_backend' => 'ini' }) } it { is_expected.to contain_icingaweb2__inisection('themes') } + it { is_expected.to contain_file('/var/log/icingaweb2') + .with_ensure('directory') + .with_mode('0750') + } + it { is_expected.to contain_file('/var/log/icingaweb2/icingaweb2.log') + .with_ensure('file') + .with_mode('0640') + } end context 'with import_schema => true and db_type => mysql' do