Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the creation of default [bw]tmp-rulesets configurable #65

Merged
merged 1 commit into from Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 10 additions & 7 deletions manifests/defaults.pp
@@ -1,8 +1,9 @@
# apply defaults
#
class logrotate::defaults (
$rules = $logrotate::params::base_rules,
$rule_default = $logrotate::params::rule_default
$create_base_rules = $logrotate::create_base_rules,
$rules = $logrotate::params::base_rules,
$rule_default = $logrotate::params::rule_default
){

assert_private()
Expand All @@ -13,11 +14,13 @@
}
}

$rules.each |$rule_name, $params| {
if !defined(Logrotate::Rule[$rule_name]) {
$_merged_params = merge($rule_default,$params)
logrotate::rule{ $rule_name:
* => $_merged_params,
if $create_base_rules {
$rules.each |$rule_name, $params| {
if !defined(Logrotate::Rule[$rule_name]) {
$_merged_params = merge($rule_default,$params)
logrotate::rule{ $rule_name:
* => $_merged_params,
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Expand Up @@ -3,6 +3,7 @@
String $ensure = present,
Boolean $hieramerge = false,
Boolean $manage_cron_daily = true,
Boolean $create_base_rules = true,
Boolean $purge_configdir = false,
String $package = 'logrotate',
Hash $rules = {},
Expand Down
9 changes: 9 additions & 0 deletions spec/classes/init_spec.rb
Expand Up @@ -62,6 +62,15 @@
'recurse' => true)
end
end

context 'logrotate class with create_base_rules set to to false' do
let(:params) { { create_base_rules: false } }

it do
is_expected.not_to contain_logrotate__rule('btmp')
is_expected.not_to contain_logrotate__rule('wtmp')
end
end
end
end
end
Expand Down