Gehel has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/342228 )

Change subject: logrotate - introduce a generic logrotate template
......................................................................

logrotate - introduce a generic logrotate template

We seem to have a lot of logrotate templates, most of which are fairly
similar. We already have a logrotate module with a very basic defined
type which manages the creation of the logrotate configuration files
but not their content. It seems natural to extend this module to
provide a default template.

The approach taken here is to provide a set of parameters to configure
logrotate, but not to provide an open ended hash of parameters. This
makes the parameters more discoverable and ensures some validity
checking.

Change-Id: I4592f57f9d1c9a9be3ffcb0b3dff4b9ffa4fa38f
---
A modules/logrotate/manifests/rule.pp
A modules/logrotate/templates/logrotate.erb
2 files changed, 76 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/28/342228/1

diff --git a/modules/logrotate/manifests/rule.pp 
b/modules/logrotate/manifests/rule.pp
new file mode 100644
index 0000000..3c4a463
--- /dev/null
+++ b/modules/logrotate/manifests/rule.pp
@@ -0,0 +1,29 @@
+# === Define logrotate::rule
+#
+# Provides a common template that can be used by different applications to
+# configure log rotation.
+#
+# The parameter of this class map directly to the corresponding logrotate
+# options.
+define logrotate::rule (
+    $ensure         = present,
+    $file_pattern   = undef,
+    $not_if_empty   = false,
+    $daily          = false,
+    $date_yesterday = false,
+    $copy_truncate  = false,
+    $max_age        = undef,
+    $rotate         = undef,
+    $date_ext       = false,
+    $compress       = false,
+    $delay_compress = false,
+    $missing_ok     = false,
+    $size           = undef,
+    $no_create      = false,
+    $post_rotate    = undef,
+) {
+    logrotate::conf { $title:
+        ensure  => $ensure,
+        content => template('logrotate/logrotate.erb'),
+    }
+}
diff --git a/modules/logrotate/templates/logrotate.erb 
b/modules/logrotate/templates/logrotate.erb
new file mode 100644
index 0000000..29d9f46
--- /dev/null
+++ b/modules/logrotate/templates/logrotate.erb
@@ -0,0 +1,47 @@
+# This file is managed by Puppet.
+# puppet:///logrotate/logrotate.erb
+
+<%= @file_pattern %> {
+<% if @not_if_empty -%>
+    notifempty
+<% end -%>
+<% if @daily -%>
+    daily
+<% end -%>
+<% if @date_yesterday -%>
+    dateyesterday
+<% end -%>
+<% if @copy_truncate -%>
+    copytruncate
+<% end -%>
+<% if @max_age -%>
+    maxage <%= @max_age %>
+<% end -%>
+<% if @rotate -%>
+    rotate <%= @rotate %>
+<% end -%>
+<% if @date_ext -%>
+    dateext
+<% end -%>
+<% if @compress -%>
+    compress
+<% end -%>
+<% if @delay_compress -%>
+    delaycompress
+<% end -%>
+<% if @missing_ok -%>
+    missingok
+<% end -%>
+<% if @size -%>
+    size <%= @size %>
+<% end -%>
+<% if @no_create -%>
+    nocreate
+<% end -%>
+<% if @post_rotate -%>
+    sharedscripts
+    postrotate
+        <%= @post_rotate %>
+    endscript
+<% end -%>
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/342228
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4592f57f9d1c9a9be3ffcb0b3dff4b9ffa4fa38f
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Gehel <guillaume.leder...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to