Browse Source

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
changes/21/213221/1
Yolanda Robla 3 years ago
parent
commit
f9f02e47d4
1 changed files with 24 additions and 12 deletions
  1. 24
    12
      templates/config.erb

+ 24
- 12
templates/config.erb View File

@@ -2,23 +2,35 @@
2 2
 <% @options.each do |opt| -%> <%= opt %>
3 3
 <% end -%>
4 4
 <% if @prerotate != 'undef' -%>
5
- prerotate
6
-  <%= @prerotate %>
7
- endscript
5
+  prerotate
6
+  <%- @prerotate = [@prerotate] unless @prerotate.is_a?(Array) -%>
7
+  <%- @prerotate.each do |val| -%>
8
+    <%= val %>
9
+  <%- end -%>
10
+  endscript
8 11
 <% end -%>
9 12
 <% if @postrotate != 'undef' -%>
10
- postrotate
11
-  <%= @postrotate %>
12
- endscript
13
+  postrotate
14
+  <%- @postrotate = [@postrotate] unless @postrotate.is_a?(Array) -%>
15
+  <%- @postrotate.each do |val| -%>
16
+    <%= val %>
17
+  <%- end -%>
18
+  endscript
13 19
 <% end -%>
14 20
 <% if @firstaction != 'undef' -%>
15
- firstaction
16
-  <%= @firstaction %>
17
- endscript
21
+  firstaction
22
+  <%- @firstaction = [@firstaction] unless @firstaction.is_a?(Array) -%>
23
+  <%- @firstaction.each do |val| -%>
24
+    <%= val %>
25
+  <%- end -%>
26
+  endscript
18 27
 <% end -%>
19 28
 <% if @lastaction != 'undef' -%>
20
- lastaction
21
-  <%= @lastaction %>
22
- endscript
29
+  lastaction
30
+  <%- @lastaction = [@lastaction] unless @lastaction.is_a?(Array) -%>
31
+  <%- @lastaction.each do |val| -%>
32
+    <%= val %>
33
+  <%- end -%>
34
+  endscript
23 35
 <% end -%>
24 36
 }

Loading…
Cancel
Save