19 changes: 17 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,24 @@ you must set an environment variable such as:

export PUPPET_VERSION="~> 4.2.0"

Install the dependencies like so...
You can install all needed gems for spec tests into the modules directory by
running:

bundle install
```sh
bundle install --path .vendor/ --without development --without system_tests --without release
```

If you also want to run acceptance tests:

```sh
bundle install --path .vendor/ --without development --with system_tests --without release
```

Our all in one solution if you don't know if you need to install or update gems:

```sh
bundle install --path .vendor/ --without development --with system_tests --without release; bundle update; bundle clean
```

## Syntax and style

Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '1.9.0'
modulesync_config_version: '1.9.2'
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ sudo: false
dist: trusty
language: ruby
cache: bundler
# related to https://github.com/rubygems/rubygems/issues/2123
before_install:
- rm -f Gemfile.lock
- 'rm -f Gemfile.lock'
- 'gem update --system'
- 'gem install bundler'
script:
- 'bundle exec rake $CHECK'
matrix:
Expand All @@ -13,16 +16,16 @@ matrix:
- rvm: 2.1.9
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 4.0" CHECK=test PARALLEL_TEST_PROCESSORS=12
- rvm: 2.4.3
- rvm: 2.4.4
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls
- rvm: 2.5.0
env: PUPPET_VERSION="~> 5.0" CHECK=test
- rvm: 2.5.1
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=test_with_coveralls
- rvm: 2.4.3
- rvm: 2.4.4
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=rubocop
- rvm: 2.4.3
- rvm: 2.5.1
bundler_args: --without system_tests development release
env: PUPPET_VERSION="~> 5.0" CHECK=build DEPLOY_TO_FORGE=yes
branches:
Expand Down
27 changes: 22 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ 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.3.0](https://github.com/voxpupuli/puppet-logrotate/tree/v3.3.0) (2018-06-25)

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

**Implemented enhancements:**

- Allow change of file mode for generated files [\#70](https://github.com/voxpupuli/puppet-logrotate/issues/70)
- Fix freebsd default rules [\#111](https://github.com/voxpupuli/puppet-logrotate/pull/111) ([kapouik](https://github.com/kapouik))
- Fix Issue 70 add file mode parameters [\#109](https://github.com/voxpupuli/puppet-logrotate/pull/109) ([TJM](https://github.com/TJM))
- Use logrotate::cron rather than file resource for hourly cron [\#105](https://github.com/voxpupuli/puppet-logrotate/pull/105) ([pjfbashton](https://github.com/pjfbashton))
- Manage logrotate startup arguments [\#102](https://github.com/voxpupuli/puppet-logrotate/pull/102) ([ruriky](https://github.com/ruriky))

**Closed issues:**

- duplicate resource or dependency cycle when attempting to set default options [\#116](https://github.com/voxpupuli/puppet-logrotate/issues/116)

**Merged pull requests:**

- \(docs\) Update readme with warning note and bigger example of defaults [\#117](https://github.com/voxpupuli/puppet-logrotate/pull/117) ([GeoffWilliams](https://github.com/GeoffWilliams))
- Remove docker nodesets [\#115](https://github.com/voxpupuli/puppet-logrotate/pull/115) ([bastelfreak](https://github.com/bastelfreak))
- drop EOL OSs; fix puppet version range [\#113](https://github.com/voxpupuli/puppet-logrotate/pull/113) ([bastelfreak](https://github.com/bastelfreak))

## [v3.2.1](https://github.com/voxpupuli/puppet-logrotate/tree/v3.2.1) (2018-03-28)

[Full Changelog](https://github.com/voxpupuli/puppet-logrotate/compare/v3.2.0...v3.2.1)
Expand Down Expand Up @@ -73,9 +95,6 @@ These should not affect the functionality of the module.

- wrong datatype for $config, s/String/Hash [\#78](https://github.com/voxpupuli/puppet-logrotate/pull/78) ([bastelfreak](https://github.com/bastelfreak))

**Merged pull requests:**


## [v3.0.0](https://github.com/voxpupuli/puppet-logrotate/tree/v3.0.0) (2017-10-10)

[Full Changelog](https://github.com/voxpupuli/puppet-logrotate/compare/v2.0.0...v3.0.0)
Expand Down Expand Up @@ -106,7 +125,6 @@ These should not affect the functionality of the module.
- Fix typo [\#58](https://github.com/voxpupuli/puppet-logrotate/pull/58) ([gabe-sky](https://github.com/gabe-sky))
- Adding support for maxsize also in main config [\#57](https://github.com/voxpupuli/puppet-logrotate/pull/57) ([seefood](https://github.com/seefood))
- Fix rubocop checks [\#53](https://github.com/voxpupuli/puppet-logrotate/pull/53) ([coreone](https://github.com/coreone))
- Another attempt at FreeBSD support [\#52](https://github.com/voxpupuli/puppet-logrotate/pull/52) ([coreone](https://github.com/coreone))
- Fixes \#34 - Ubuntu Xenial and up support [\#43](https://github.com/voxpupuli/puppet-logrotate/pull/43) ([edestecd](https://github.com/edestecd))
- Fixes \#37 - Logrotate rule ERB template should not take variables from the scope object [\#38](https://github.com/voxpupuli/puppet-logrotate/pull/38) ([imriz](https://github.com/imriz))
- Fix puppet-lint issues and bad style [\#32](https://github.com/voxpupuli/puppet-logrotate/pull/32) ([baurmatt](https://github.com/baurmatt))
Expand All @@ -129,7 +147,6 @@ These should not affect the functionality of the module.
- remove special whitespace character [\#20](https://github.com/voxpupuli/puppet-logrotate/pull/20) ([jfroche](https://github.com/jfroche))
- Update Gemfile for Rake/Ruby version dependencies [\#19](https://github.com/voxpupuli/puppet-logrotate/pull/19) ([ncsutmf](https://github.com/ncsutmf))
- add official puppet 4 support [\#17](https://github.com/voxpupuli/puppet-logrotate/pull/17) ([mmckinst](https://github.com/mmckinst))
- Feature/fix wtmp btmp [\#16](https://github.com/voxpupuli/puppet-logrotate/pull/16) ([robinbowes](https://github.com/robinbowes))

## [v1.3.0](https://github.com/voxpupuli/puppet-logrotate/tree/v1.3.0) (2015-11-05)

Expand Down
11 changes: 6 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ group :test do
gem 'redcarpet', :require => false
gem 'rubocop', '~> 0.49.1', :require => false if RUBY_VERSION >= '2.3.0'
gem 'rubocop-rspec', '~> 1.15.0', :require => false if RUBY_VERSION >= '2.3.0'
gem 'mocha', '>= 1.2.1', :require => false
gem 'mocha', '~> 1.4.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'rack', '~> 1.0', :require => false if RUBY_VERSION < '2.2.2'
Expand All @@ -40,7 +40,7 @@ group :development do
end

group :system_tests do
gem 'winrm', :require => false
gem 'winrm', :require => false
if beaker_version = ENV['BEAKER_VERSION']
gem 'beaker', *location_for(beaker_version)
else
Expand All @@ -51,9 +51,10 @@ group :system_tests do
else
gem 'beaker-rspec', :require => false
end
gem 'serverspec', :require => false
gem 'beaker-puppet_install_helper', :require => false
gem 'beaker-module_install_helper', :require => false
gem 'serverspec', :require => false
gem 'beaker-hostgenerator', '>= 1.1.10', :require => false
gem 'beaker-puppet_install_helper', :require => false
gem 'beaker-module_install_helper', :require => false
end

group :release do
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ You may, optionally, define logrotate defaults using this defined type.
Parameters are the same as those for logrotate::rule.
Using this type will automatically include a private class that will install
and configure logrotate for you.
You must not also declare the `logrotate` class if using this defined type as you will encounter a Puppet error if you attempt to do so.

## logrotate::rule

Expand Down Expand Up @@ -148,13 +149,28 @@ This example will ensure that the logrotate package is latest and that the `date
class { '::logrotate':
ensure => 'latest',
config => {
dateext => true,
compress => true,
dateext => true,
compress => true,
rotate => 10,
rotate_every => 'week',
ifempty => true,
}
}
```

### Additional startup arguments

With parameter `logrotate_args` you can specify additional startup arguments for logrotate. Configuration file is always added as the last argument for logrotate.

This example tells logrotate to use an alternate state file and which command to use when mailing logs.

```puppet
class { '::logrotate':
ensure => 'latest',
logrotate_args => ['-s /var/lib/logrotate/logrotate.status', '-m /usr/local/bin/mailer']
}
}
```
## Examples

```puppet
Expand Down
2 changes: 1 addition & 1 deletion manifests/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
ensure => $ensure,
owner => $logrotate::root_user,
group => $logrotate::root_group,
mode => '0444',
mode => $logrotate::logrotate_conf_mode,
content => template('logrotate/etc/logrotate.conf.erb'),
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
group => $logrotate::root_group,
purge => $::logrotate::purge_configdir,
recurse => $::logrotate::purge_configdir,
mode => '0755',
mode => $logrotate::rules_configdir_mode,
}

if $manage_cron_daily {
Expand Down
24 changes: 17 additions & 7 deletions manifests/cron.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,33 @@
default => "/etc/cron.${name}/logrotate",
}

$logrotate_path = $::logrotate::logrotate_bin
$logrotate_path = $logrotate::logrotate_bin

if $name == 'hourly' {
$logrotate_arg = "${::logrotate::rules_configdir}/hourly"
$logrotate_conf = "${logrotate::rules_configdir}/hourly"
} else {
$logrotate_arg = $::logrotate::logrotate_conf
$logrotate_conf = $logrotate::logrotate_conf
}

# If the logrotation config file is not yet in the arguments, add it
if ! ($logrotate_conf in $logrotate::logrotate_args) {
$_logrotate_args = concat($logrotate::logrotate_args,$logrotate_conf)
}
else {
$_logrotate_args = $logrotate::logrotate_args
}

$logrotate_args = join($_logrotate_args, ' ')

# FreeBSD does not have /etc/cron.daily, so we need to have Puppet maintain
# a crontab entry
if $::osfamily == 'FreeBSD' {
if $name == 'hourly' {
$cron_hour = '*'
$cron_minute = $::logrotate::cron_hourly_minute
$cron_minute = $logrotate::cron_hourly_minute
} else {
$cron_hour = $::logrotate::cron_daily_hour
$cron_minute = $::logrotate::cron_daily_minute
$cron_hour = $logrotate::cron_daily_hour
$cron_minute = $logrotate::cron_daily_minute
}

cron { "logrotate_${name}":
Expand All @@ -38,7 +48,7 @@
ensure => $ensure,
owner => $logrotate::root_user,
group => $logrotate::root_group,
mode => '0555',
mode => $logrotate::cron_file_mode,
content => template('logrotate/etc/cron/logrotate.erb'),
}
}
14 changes: 5 additions & 9 deletions manifests/hourly.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@
ensure => $dir_ensure,
owner => 'root',
group => 'root',
mode => '0755',
}
file { $logrotate::cron_hourly_file:
ensure => $ensure,
owner => 'root',
group => 'root',
mode => '0555',
source => 'puppet:///modules/logrotate/etc/cron.hourly/logrotate',
require => [File["${logrotate::rules_configdir}/hourly"],Package['logrotate']],
mode => $logrotate::rules_configdir_mode,
}
-> logrotate::cron { 'hourly':
ensure => $ensure,
}

}
42 changes: 23 additions & 19 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
#
class logrotate (
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,
Integer[0,23] $cron_daily_hour = $logrotate::params::cron_daily_hour,
Integer[0,59] $cron_daily_minute = $logrotate::params::cron_daily_minute,
Integer[0,59] $cron_hourly_minute = $logrotate::params::cron_hourly_minute,
String $cron_hourly_file = $logrotate::params::cron_hourly_file,
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,
String $root_user = $logrotate::params::root_user,
String $root_group = $logrotate::params::root_group,
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,
Integer[0,23] $cron_daily_hour = $logrotate::params::cron_daily_hour,
Integer[0,59] $cron_daily_minute = $logrotate::params::cron_daily_minute,
Integer[0,59] $cron_hourly_minute = $logrotate::params::cron_hourly_minute,
String $cron_hourly_file = $logrotate::params::cron_hourly_file,
Stdlib::Filemode $cron_file_mode = $logrotate::params::cron_file_mode,
String $configdir = $logrotate::params::configdir,
String $logrotate_bin = $logrotate::params::logrotate_bin,
String $logrotate_conf = $logrotate::params::logrotate_conf,
Stdlib::Filemode $logrotate_conf_mode = $logrotate::params::logrotate_conf_mode,
Boolean $manage_package = $logrotate::params::manage_package,
String $rules_configdir = $logrotate::params::rules_configdir,
Stdlib::Filemode $rules_configdir_mode = $logrotate::params::rules_configdir_mode,
String $root_user = $logrotate::params::root_user,
String $root_group = $logrotate::params::root_group,
Array[String] $logrotate_args = []
) inherits logrotate::params {

contain ::logrotate::install
Expand Down
18 changes: 8 additions & 10 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,7 @@
$conf_params = {
su_group => undef,
}
$base_rules = {
'wtmp' => {
path => '/var/log/wtmp',
create_mode => '0664',
},
'btmp' => {
path => '/var/log/btmp',
create_mode => '0600',
},
}
$base_rules = {}
$rule_default = {
missingok => true,
rotate_every => 'monthly',
Expand Down Expand Up @@ -188,4 +179,11 @@
$manage_package = true
$root_user = 'root'
$rules_configdir = "${configdir}/logrotate.d"

# File modes (permissions)
# - These may need to be moved to the osfamily case statement
# - These are currently matching the RedHat RPM permissions
$cron_file_mode = '0700'
$logrotate_conf_mode = '0644'
$rules_configdir_mode = '0755'
}
2 changes: 1 addition & 1 deletion manifests/rule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
ensure => $ensure,
owner => $logrotate::root_user,
group => $logrotate::root_group,
mode => '0444',
mode => $logrotate::logrotate_conf_mode,
content => template('logrotate/etc/logrotate.d/rule.erb'),
require => Class['::logrotate::config'],
}
Expand Down
Loading