-
Notifications
You must be signed in to change notification settings - Fork 236
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 logrotate.conf into a template with defined type #15
Open
apowers
wants to merge
3
commits into
rodjek:master
Choose a base branch
from
seattle-biomed:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,278 @@ | ||
# Internal: Install and configure logrotate defaults file, usually | ||
# /etc/logrotate.conf | ||
# | ||
# see logrotate::rule for description of options. | ||
# | ||
# Examples | ||
# | ||
# logrotate::conf{'/etc/logrotate.conf':} | ||
# | ||
define logrotate::conf ( | ||
$ensure = 'present', | ||
$compress = 'undef', | ||
$compresscmd = 'undef', | ||
$compressext = 'undef', | ||
$compressoptions = 'undef', | ||
$copy = 'undef', | ||
$copytruncate = 'undef', | ||
$create = true, | ||
$create_mode = 'undef', | ||
$create_owner = 'undef', | ||
$create_group = 'undef', | ||
$dateext = 'undef', | ||
$dateformat = 'undef', | ||
$delaycompress = 'undef', | ||
$extension = 'undef', | ||
$ifempty = 'undef', | ||
$mail = 'undef', | ||
$mailfirst = 'undef', | ||
$maillast = 'undef', | ||
$maxage = 'undef', | ||
$minsize = 'undef', | ||
$missingok = 'undef', | ||
$olddir = 'undef', | ||
$postrotate = 'undef', | ||
$prerotate = 'undef', | ||
$firstaction = 'undef', | ||
$lastaction = 'undef', | ||
$rotate = '4', | ||
$rotate_every = 'weekly', | ||
$size = 'undef', | ||
$sharedscripts = 'undef', | ||
$shred = 'undef', | ||
$shredcycles = 'undef', | ||
$start = 'undef', | ||
$uncompresscmd = 'undef' | ||
) { | ||
|
||
############################################################################# | ||
# SANITY CHECK VALUES | ||
|
||
if $name !~ /^[a-zA-Z0-9\._\/-]+$/ { | ||
fail("Logrotate::Rule[${name}]: namevar must be alphanumeric") | ||
} | ||
|
||
case $ensure { | ||
'present','file': {} | ||
'absent': {} | ||
default: { | ||
fail("Logrotate::Rule[${name}]: invalid ensure value") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All instances of Logrotate::Rule in the fail messages in this class should be Logrotate::Conf |
||
} | ||
} | ||
|
||
case $compress { | ||
'undef': {} | ||
true: { $_compress = 'compress' } | ||
false: { $_compress = 'nocompress' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: compress must be a boolean") | ||
} | ||
} | ||
|
||
case $copy { | ||
'undef': {} | ||
true: { $_copy = 'copy' } | ||
false: { $_copy = 'nocopy' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: copy must be a boolean") | ||
} | ||
} | ||
|
||
case $copytruncate { | ||
'undef': {} | ||
true: { $_copytruncate = 'copytruncate' } | ||
false: { $_copytruncate = 'nocopytruncate' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: copytruncate must be a boolean") | ||
} | ||
} | ||
|
||
case $create { | ||
'undef': {} | ||
true: { $_create = 'create' } | ||
false: { $_create = 'nocreate' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: create must be a boolean") | ||
} | ||
} | ||
|
||
case $delaycompress { | ||
'undef': {} | ||
true: { $_delaycompress = 'delaycompress' } | ||
false: { $_delaycompress = 'nodelaycompress' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: delaycompress must be a boolean") | ||
} | ||
} | ||
|
||
case $dateext { | ||
'undef': {} | ||
true: { $_dateext = 'dateext' } | ||
false: { $_dateext = 'nodateext' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: dateext must be a boolean") | ||
} | ||
} | ||
|
||
case $mail { | ||
'undef': {} | ||
false: { $_mail = 'nomail' } | ||
default: { | ||
$_mail = "mail ${mail}" | ||
} | ||
} | ||
|
||
case $missingok { | ||
'undef': {} | ||
true: { $_missingok = 'missingok' } | ||
false: { $_missingok = 'nomissingok' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: missingok must be a boolean") | ||
} | ||
} | ||
|
||
case $olddir { | ||
'undef': {} | ||
false: { $_olddir = 'noolddir' } | ||
default: { | ||
$_olddir = "olddir ${olddir}" | ||
} | ||
} | ||
|
||
case $sharedscripts { | ||
'undef': {} | ||
true: { $_sharedscripts = 'sharedscripts' } | ||
false: { $_sharedscripts = 'nosharedscripts' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: sharedscripts must be a boolean") | ||
} | ||
} | ||
|
||
case $shred { | ||
'undef': {} | ||
true: { $_shred = 'shred' } | ||
false: { $_shred = 'noshred' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: shred must be a boolean") | ||
} | ||
} | ||
|
||
case $ifempty { | ||
'undef': {} | ||
true: { $_ifempty = 'ifempty' } | ||
false: { $_ifempty = 'notifempty' } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: ifempty must be a boolean") | ||
} | ||
} | ||
|
||
case $rotate_every { | ||
'undef': {} | ||
'day': { $_rotate_every = 'daily' } | ||
'week': { $_rotate_every = 'weekly' } | ||
'month': { $_rotate_every = 'monthly' } | ||
'year': { $_rotate_every = 'yearly' } | ||
'daily', 'weekly','monthly','yearly': { $_rotate_every = $rotate_every } | ||
default: { | ||
fail("Logrotate::Rule[${name}]: invalid rotate_every value") | ||
} | ||
} | ||
|
||
case $maxage { | ||
'undef': {} | ||
/^\d+$/: {} | ||
default: { | ||
fail("Logrotate::Rule[${name}]: maxage must be an integer") | ||
} | ||
} | ||
|
||
case $minsize { | ||
'undef': {} | ||
/^\d+[kMG]?$/: {} | ||
default: { | ||
fail("Logrotate::Rule[${name}]: minsize must match /\\d+[kMG]?/") | ||
} | ||
} | ||
|
||
case $rotate { | ||
'undef': {} | ||
/^\d+$/: {} | ||
default: { | ||
fail("Logrotate::Rule[${name}]: rotate must be an integer") | ||
} | ||
} | ||
|
||
case $size { | ||
'undef': {} | ||
/^\d+[kMG]?$/: {} | ||
default: { | ||
fail("Logrotate::Rule[${name}]: size must match /\\d+[kMG]?/") | ||
} | ||
} | ||
|
||
case $shredcycles { | ||
'undef': {} | ||
/^\d+$/: {} | ||
default: { | ||
fail("Logrotate::Rule[${name}]: shredcycles must be an integer") | ||
} | ||
} | ||
|
||
case $start { | ||
'undef': {} | ||
/^\d+$/: {} | ||
default: { | ||
fail("Logrotate::Rule[${name}]: start must be an integer") | ||
} | ||
} | ||
|
||
case $mailfirst { | ||
'undef',false: {} | ||
true: { | ||
if $maillast == true { | ||
fail("Logrotate::Rule[${name}]: Can't set both mailfirst and maillast") | ||
} | ||
|
||
$_mailfirst = 'mailfirst' | ||
} | ||
default: { | ||
fail("Logrotate::Rule[${name}]: mailfirst must be a boolean") | ||
} | ||
} | ||
|
||
case $maillast { | ||
'undef',false: {} | ||
true: { | ||
$_maillast = 'maillast' | ||
} | ||
default: { | ||
fail("Logrotate::Rule[${name}]: maillast must be a boolean") | ||
} | ||
} | ||
|
||
if ($create_group != 'undef') and ($create_owner == 'undef') { | ||
fail("Logrotate::Rule[${name}]: create_group requires create_owner") | ||
} | ||
|
||
if ($create_owner != 'undef') and ($create_mode == 'undef') { | ||
fail("Logrotate::Rule[${name}]: create_owner requires create_mode") | ||
} | ||
|
||
if ($create_mode != 'undef') and ($create != true) { | ||
fail("Logrotate::Rule[${name}]: create_mode requires create") | ||
} | ||
|
||
# | ||
#################################################################### | ||
|
||
include logrotate::base | ||
|
||
file { $name: | ||
ensure => $ensure, | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0444', | ||
content => template('logrotate/etc/logrotate.conf.erb'), | ||
require => Package['logrotate'], | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo - should be "present"