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

Added possibility to define package state #59

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions files/etc/logrotate.conf

This file was deleted.

13 changes: 10 additions & 3 deletions manifests/base.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
# Examples
#
# include logrotate::base
class logrotate::base {
class logrotate::base (
$compress = true,
$compresscmd = undef,
$compressext = undef,
$dateext = false,
$package_state = 'present',
$rotate = 4
){
package { 'logrotate':
ensure => latest,
ensure => $package_state,
}

File {
Expand All @@ -18,7 +25,7 @@
'/etc/logrotate.conf':
ensure => file,
mode => '0444',
source => 'puppet:///modules/logrotate/etc/logrotate.conf';
content => template('logrotate/etc/logrotate.conf.erb'),;
'/etc/logrotate.d':
ensure => directory,
mode => '0755';
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'logrotate::base' do
it do
should contain_package('logrotate').with_ensure('latest')
should contain_package('logrotate').with_ensure('present')

should contain_file('/etc/logrotate.conf').with({
'ensure' => 'file',
Expand Down
33 changes: 33 additions & 0 deletions templates/etc/logrotate.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET. ANY CHANGES WILL BE
# OVERWRITTEN.

# Default values
# rotate log files weekly
weekly

# keep X weeks worth of backlogs
rotate <%= @rotate %>

# create new (empty) log files after rotating old ones
create

<% if @compress -%>
compress
<%- end -%>

<% if @compresscmd -%>
compresscmd <%= @compresscmd %>
<%- end -%>

<% if @compressext -%>
compressext <%= @compressext %>
<%- end -%>

<% if @dateext -%>
# use date as a suffix of the rotated file
dateext
<%- end -%>


# packages drop log rotation information into this directory
include /etc/logrotate.d