Showing with 153 additions and 47 deletions.
  1. +1 −1 .msync.yml
  2. +1 −1 .rubocop.yml
  3. +2 −7 .travis.yml
  4. +37 −1 CHANGELOG.md
  5. +2 −2 Gemfile
  6. +0 −3 README.md
  7. +27 −0 Rakefile
  8. +7 −3 manifests/conf.pp
  9. +6 −4 manifests/config.pp
  10. +10 −7 manifests/defaults.pp
  11. +6 −3 manifests/init.pp
  12. +5 −3 manifests/install.pp
  13. +7 −1 manifests/params.pp
  14. +2 −5 manifests/rule.pp
  15. +2 −2 metadata.json
  16. +8 −2 spec/classes/defaults_spec.rb
  17. +30 −0 spec/classes/init_spec.rb
  18. +0 −1 types/ensurable.pp
  19. +0 −1 types/userorgroup.pp
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '1.4.1'
modulesync_config_version: '1.6.0'
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Style/HashSyntax:
Style/RedundantReturn:
Enabled: True

Style/EndOfLine:
Layout/EndOfLine:
Enabled: False

Lint/AmbiguousOperator:
Expand Down
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ dist: trusty
language: ruby
cache: bundler
before_install:
- bundle -v
- rm Gemfile.lock || true
- gem update --system
- gem update bundler
- gem --version
- bundle -v
- rm -f Gemfile.lock
script:
- 'bundle exec rake $CHECK'
matrix:
fast_finish: true
include:
- rvm: 2.1.9
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 4.0" CHECK=test
env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=16
- rvm: 2.4.2
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls
Expand Down
38 changes: 37 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,42 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v3.2.0](https://github.com/voxpupuli/puppet-logrotate/tree/v3.2.0) (2018-01-04)

[Full Changelog](https://github.com/voxpupuli/puppet-logrotate/compare/v3.1.0...v3.2.0)

**Implemented enhancements:**

- Deprecation warnings from newer stdlib [\#54](https://github.com/voxpupuli/puppet-logrotate/issues/54)
- Add manage\_package parameter [\#97](https://github.com/voxpupuli/puppet-logrotate/pull/97) ([juniorsysadmin](https://github.com/juniorsysadmin))
- Make the creation of default \[bw\]tmp-rulesets configurable [\#65](https://github.com/voxpupuli/puppet-logrotate/pull/65) ([mcgege](https://github.com/mcgege))
- Add purge\_configdir to purge old configs [\#23](https://github.com/voxpupuli/puppet-logrotate/pull/23) ([patricktoelle](https://github.com/patricktoelle))

**Fixed bugs:**

- 'su root syslog' line missing in default logrotate.conf file for Ubuntu produced by this module [\#93](https://github.com/voxpupuli/puppet-logrotate/issues/93)
- Pattern matcher in Logrotate::UserOrGroup is too strict. Doesn't allow names with domain. [\#88](https://github.com/voxpupuli/puppet-logrotate/issues/88)
- Enum on package ensure is too restrictive [\#84](https://github.com/voxpupuli/puppet-logrotate/issues/84)
- logrotate::conf\[/etc/logrotate.conf\] [\#49](https://github.com/voxpupuli/puppet-logrotate/issues/49)
- copy and copytruncate marked in rules.pp as optional [\#31](https://github.com/voxpupuli/puppet-logrotate/issues/31)
- copytruncate =\> true affects logrotate::defaults wtmp and btmp rules [\#22](https://github.com/voxpupuli/puppet-logrotate/issues/22)
- Remove UserOrGroup type, use String [\#98](https://github.com/voxpupuli/puppet-logrotate/pull/98) ([juniorsysadmin](https://github.com/juniorsysadmin))
- Allow logrotate version to be specified [\#96](https://github.com/voxpupuli/puppet-logrotate/pull/96) ([juniorsysadmin](https://github.com/juniorsysadmin))
- Fix missing su line in default logrotate.conf on Ubuntu [\#92](https://github.com/voxpupuli/puppet-logrotate/pull/92) ([szponek](https://github.com/szponek))
- Add missing $maxsize option to Logrotate::Conf [\#90](https://github.com/voxpupuli/puppet-logrotate/pull/90) ([achermes](https://github.com/achermes))

**Closed issues:**

- parameter 'path' references an unresolved type 'Stdlib::UnixPath' [\#95](https://github.com/voxpupuli/puppet-logrotate/issues/95)
- Add option to not manage logrotate package [\#44](https://github.com/voxpupuli/puppet-logrotate/issues/44)
- logrotate::rule adds blank su to wtmp and btmp [\#41](https://github.com/voxpupuli/puppet-logrotate/issues/41)
- Add tests for all OSes for defaults.pp [\#3](https://github.com/voxpupuli/puppet-logrotate/issues/3)

**Merged pull requests:**

- Remove obsolete su parameter in documentation [\#91](https://github.com/voxpupuli/puppet-logrotate/pull/91) ([stefanandres](https://github.com/stefanandres))
- release 3.1.0 [\#87](https://github.com/voxpupuli/puppet-logrotate/pull/87) ([bastelfreak](https://github.com/bastelfreak))

## [v3.1.0](https://github.com/voxpupuli/puppet-logrotate/tree/v3.1.0) (2017-11-13)

[Full Changelog](https://github.com/voxpupuli/puppet-logrotate/compare/v3.0.1...v3.1.0)
Expand Down Expand Up @@ -147,4 +183,4 @@ These should not affect the functionality of the module.
- First release to puppetforge


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def location_for(place, fake_version = nil)
end

group :test do
gem 'puppetlabs_spec_helper', '~> 2.4.0', :require => false
gem 'puppetlabs_spec_helper', '~> 2.5.0', :require => false
gem 'rspec-puppet', '~> 2.5', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rspec-puppet-utils', :require => false
Expand Down Expand Up @@ -57,7 +57,7 @@ group :system_tests do
end

group :release do
gem 'github_changelog_generator', :require => false if RUBY_VERSION >= '2.2.2'
gem 'github_changelog_generator', :require => false, :git => 'https://github.com/skywinder/github-changelog-generator'
gem 'puppet-blacksmith', :require => false
gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem'
gem 'puppet-strings', '~> 1.0', :require => false
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ shredcycles - The Integer number of times shred should overwrite log files
before unlinking them (optional).
start - The Integer number to be used as the base for the extensions
appended to the rotated log files (optional).
su - A Boolean specifying whether logrotate should rotate under
the specific su_owner and su_group instead of the default.
First available in logrotate 3.8.0. (optional)
su_owner - A username String that logrotate should use to rotate a
log file set instead of using the default if
su => true (optional).
Expand Down
27 changes: 27 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ exclude_paths = %w(
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths

desc 'Auto-correct puppet-lint offenses'
task 'lint:auto_correct' do
PuppetLint.configuration.fix = true
Rake::Task[:lint].invoke
end

desc 'Run acceptance tests'
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
Expand All @@ -48,6 +54,27 @@ task test_with_coveralls: [:test] do
end
end

desc "Print supported beaker sets"
task 'beaker_sets', [:directory] do |t, args|
directory = args[:directory]

metadata = JSON.load(File.read('metadata.json'))

(metadata['operatingsystem_support'] || []).each do |os|
(os['operatingsystemrelease'] || []).each do |release|
if directory
beaker_set = "#{directory}/#{os['operatingsystem'].downcase}-#{release}"
else
beaker_set = "#{os['operatingsystem'].downcase}-#{release}-x64"
end

filename = "spec/acceptance/nodesets/#{beaker_set}.yml"

puts beaker_set if File.exists? filename
end
end
end

begin
require 'github_changelog_generator/task'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
Expand Down
10 changes: 7 additions & 3 deletions manifests/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Optional[Enum['mailfirst', 'maillast']] $mail_when = undef,
Optional[Integer] $maxage = undef,
Optional[Logrotate::Size] $minsize = undef,
Optional[Logrotate::Size] $maxsize = undef,
Optional[Boolean] $missingok = undef,
Optional[Variant[Boolean,String]] $olddir = undef,
Optional[String] $postrotate = undef,
Expand All @@ -43,8 +44,8 @@
Optional[Boolean] $shred = undef,
Optional[Integer] $shredcycles = undef,
Optional[Integer] $start = undef,
Optional[Logrotate::UserOrGroup] $su_user = undef,
Optional[Logrotate::UserOrGroup] $su_group = undef,
Optional[String] $su_user = undef,
Optional[String] $su_group = undef,
Optional[String] $uncompresscmd = undef
) {

Expand Down Expand Up @@ -105,6 +106,9 @@
group => $logrotate::root_group,
mode => '0444',
content => template('logrotate/etc/logrotate.conf.erb'),
require => Package['logrotate'],
}

if $logrotate::manage_package {
Package[$logrotate::package] -> File[$path]
}
}
10 changes: 6 additions & 4 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
$config = $::logrotate::config

file{ $::logrotate::rules_configdir:
ensure => directory,
owner => $logrotate::root_user,
group => $logrotate::root_group,
mode => '0755',
ensure => directory,
owner => $logrotate::root_user,
group => $logrotate::root_group,
purge => $::logrotate::purge_configdir,
recurse => $::logrotate::purge_configdir,
mode => '0755',
}

if $manage_cron_daily {
Expand Down
17 changes: 10 additions & 7 deletions manifests/defaults.pp
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#
class logrotate (
Logrotate::Ensurable $ensure = present,
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 = {},
Optional[Hash] $config = undef,
Expand All @@ -13,9 +15,10 @@
String $configdir = $logrotate::params::configdir,
String $logrotate_bin = $logrotate::params::logrotate_bin,
String $logrotate_conf = $logrotate::params::logrotate_conf,
Boolean $manage_package = $logrotate::params::manage_package,
String $rules_configdir = $logrotate::params::rules_configdir,
Logrotate::UserOrGroup $root_user = $logrotate::params::root_user,
Logrotate::UserOrGroup $root_group = $logrotate::params::root_group,
String $root_user = $logrotate::params::root_user,
String $root_group = $logrotate::params::root_group,
) inherits logrotate::params {

contain ::logrotate::install
Expand Down
8 changes: 5 additions & 3 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

assert_private()

package { $::logrotate::package:
ensure => $::logrotate::ensure,
if $logrotate::manage_package {
package { $logrotate::package:
ensure => $logrotate::ensure,
}
}

}
}
8 changes: 7 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@
}
}
'Debian': {
$default_su_group = versioncmp($::operatingsystemmajrelease, '14.00') ? {
$default_su_user = versioncmp($facts['operatingsystemmajrelease'], '14.00') ? {
1 => 'root',
default => undef,
}
$default_su_group = versioncmp($facts['operatingsystemmajrelease'], '14.00') ? {
1 => 'syslog',
default => undef
}
$conf_params = {
su_user => $default_su_user,
su_group => $default_su_group,
}
$configdir = '/etc'
Expand Down Expand Up @@ -180,6 +185,7 @@
$cron_hourly_file = '/etc/cron.hourly/logrotate'
$config_file = "${configdir}/logrotate.conf"
$logrotate_conf = "${configdir}/logrotate.conf"
$manage_package = true
$root_user = 'root'
$rules_configdir = "${configdir}/logrotate.d"
}
7 changes: 2 additions & 5 deletions manifests/rule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@
# before unlinking them (optional).
# start - The Integer number to be used as the base for the extensions
# appended to the rotated log files (optional).
# su - A Boolean specifying whether logrotate should rotate under
# the specific su_owner and su_group instead of the default.
# First available in logrotate 3.8.0. (optional)
# su_owner - A username String that logrotate should use to rotate a
# log file set instead of using the default if
# su => true (optional).
Expand Down Expand Up @@ -161,8 +158,8 @@
Optional[Boolean] $shred = undef,
Optional[Integer] $shredcycles = undef,
Optional[Integer] $start = undef,
Optional[Logrotate::UserOrGroup] $su_owner = undef,
Optional[Logrotate::UserOrGroup] $su_group = undef,
Optional[String] $su_owner = undef,
Optional[String] $su_group = undef,
Optional[String] $uncompresscmd = undef
) {
case $ensure {
Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-logrotate",
"version": "3.1.0",
"version": "3.2.0",
"author": "Vox Pupuli",
"summary": "Manage logrotate",
"license": "MIT",
Expand All @@ -19,7 +19,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 4.7.0 < 6.0.0"
"version_requirement": ">= 4.7.1 < 6.0.0"
}
],
"operatingsystem_support": [
Expand Down
10 changes: 8 additions & 2 deletions spec/classes/defaults_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

if facts[:operatingsystem] == 'Ubuntu' && facts[:operatingsystemmajrelease].to_i >= 14
it {
is_expected.to contain_logrotate__conf('/etc/logrotate.conf').with_su_group('syslog')
is_expected.to contain_logrotate__conf('/etc/logrotate.conf').with(
'su_user' => 'root',
'su_group' => 'syslog'
)
}
else
it {
is_expected.to contain_logrotate__conf('/etc/logrotate.conf').with_su_group(nil)
is_expected.to contain_logrotate__conf('/etc/logrotate.conf').with(
'su_user' => nil,
'su_group' => nil
)
}
end
it {
Expand Down
30 changes: 30 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,36 @@
is_expected.to contain_class('logrotate::defaults')
end
end

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

it do
is_expected.not_to contain_package('logrotate')
end
end

context 'logrotate class with purge_configdir set to true' do
let(:params) { { purge_configdir: true } }

it do
is_expected.to contain_file('/etc/logrotate.d').with('ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0755',
'purge' => true,
'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
1 change: 0 additions & 1 deletion types/ensurable.pp

This file was deleted.

1 change: 0 additions & 1 deletion types/userorgroup.pp

This file was deleted.