From f9f02e47d4b768e767a0516841ed4164a12081ae Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Fri, 14 Aug 2015 18:02:45 +0200 Subject: [PATCH] Allow logrotation actions to be string or array For prerotate, logrotate, firstaction and lastaction is very common to need several lines of commands, making it difficult to pass with a puppet string. Allow this parameter to be either and string or an array to allow this usage. Change-Id: I7451ecc550b50b85c55784ef598f6b45412117fc --- templates/config.erb | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/templates/config.erb b/templates/config.erb index 619c299..0a14d43 100644 --- a/templates/config.erb +++ b/templates/config.erb @@ -2,23 +2,35 @@ <% @options.each do |opt| -%> <%= opt %> <% end -%> <% if @prerotate != 'undef' -%> - prerotate - <%= @prerotate %> - endscript + prerotate + <%- @prerotate = [@prerotate] unless @prerotate.is_a?(Array) -%> + <%- @prerotate.each do |val| -%> + <%= val %> + <%- end -%> + endscript <% end -%> <% if @postrotate != 'undef' -%> - postrotate - <%= @postrotate %> - endscript + postrotate + <%- @postrotate = [@postrotate] unless @postrotate.is_a?(Array) -%> + <%- @postrotate.each do |val| -%> + <%= val %> + <%- end -%> + endscript <% end -%> <% if @firstaction != 'undef' -%> - firstaction - <%= @firstaction %> - endscript + firstaction + <%- @firstaction = [@firstaction] unless @firstaction.is_a?(Array) -%> + <%- @firstaction.each do |val| -%> + <%= val %> + <%- end -%> + endscript <% end -%> <% if @lastaction != 'undef' -%> - lastaction - <%= @lastaction %> - endscript + lastaction + <%- @lastaction = [@lastaction] unless @lastaction.is_a?(Array) -%> + <%- @lastaction.each do |val| -%> + <%= val %> + <%- end -%> + endscript <% end -%> }