Skip to content

Commit b63848a

Browse files
committed
simplify some comparisons in templates
1 parent 3de3e42 commit b63848a

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

REFERENCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,11 @@ Default value: `undef`
986986

987987
##### <a name="-rsyslog--server--rules"></a>`rules`
988988

989-
Data type: `Optional[Array[Hash]]`
989+
Data type: `Array[Hash]`
990990

991991
Array of hashes for configuring custom rules for the server. If set, this replaces the default rules
992992

993-
Default value: `undef`
993+
Default value: `[]`
994994

995995
## Defined types
996996

manifests/server.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
Optional[String[1]] $actionfiletemplate_cust = undef,
119119
Optional[String[1]] $actionfiletemplate = undef,
120120
Optional[Enum['year', 'YEAR', 'month', 'MONTH', 'day', 'DAY']] $rotate = undef,
121-
Optional[Array[Hash]] $rules = undef,
121+
Array[Hash] $rules = [],
122122
) inherits rsyslog::params {
123123
include rsyslog
124124

templates/client/config.conf.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ $template <%= @actionfiletemplate %>, <%= @actionfiletemplate_cust %>
3333
$ActionFileDefaultTemplate <%= @actionfiletemplate %>
3434
<% else -%>
3535

36-
<% if @high_precision_timestamps == false -%>
37-
# Use default format
38-
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
39-
<% else -%>
36+
<% if @high_precision_timestamps -%>
4037
# Use high precision timestamp format.
4138
$ActionFileDefaultTemplate RSYSLOG_FileFormat
39+
<% else -%>
40+
# Use default format
41+
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
4242
<% end -%>
4343
<% end -%>
4444

templates/rsyslog.conf.erb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $MaxMessageSize <%= @max_message_size %>
55
<% if @preserve_fqdn -%>
66
$PreserveFQDN on
77
<% end -%>
8-
<% if @local_host_name and @local_host_name != :undef -%>
8+
<% if @local_host_name -%>
99
$LocalHostName <%= @local_host_name %>
1010
<% end -%>
1111

@@ -32,21 +32,21 @@ $KLogPermitNonKernelFacility on
3232
#
3333
# Set rate limit for messages received.
3434
#
35-
<%- if @system_log_rate_limit_interval and @system_log_rate_limit_interval != :undef-%>
35+
<%- if @system_log_rate_limit_interval -%>
3636
$SystemLogRateLimitInterval <%= @system_log_rate_limit_interval %>
3737
<%- end -%>
38-
<%- if @system_log_rate_limit_burst and @system_log_rate_limit_burst != :undef -%>
38+
<%- if @system_log_rate_limit_burst -%>
3939
$SystemLogRateLimitBurst <%= @system_log_rate_limit_burst %>
4040
<%- end -%>
4141

42-
<% if @default_template and @default_template != :undef and @default_template_customisation and @default_template_customisation != :undef -%>
42+
<% if @default_template and @default_template_customisation -%>
4343
#
4444
# Custom setting for ActionFileDefaultTemplate
4545
#
4646
$template <%= @default_template %>,<%= @default_template_customisation %>
4747

4848
<% end -%>
49-
<% if @default_template and @default_template != :undef -%>
49+
<% if @default_template -%>
5050
#
5151
# Sets a default template for file action
5252
#
@@ -81,16 +81,16 @@ $OmitLocalLogging on
8181
<% end -%>
8282

8383
# Settings for imjournal (If supported)
84-
<% if @im_journal_statefile and @im_journal_statefile != :undef -%>
84+
<% if @im_journal_statefile -%>
8585
$imjournalStateFile <%=@im_journal_statefile %>
8686
<% end -%>
87-
<% if @im_journal_ignore_previous_messages and @im_journal_ignore_previous_messages != :undef -%>
87+
<% if @im_journal_ignore_previous_messages -%>
8888
$imjournalIgnorePreviousMessages <%=@im_journal_ignore_previous_messages %>
8989
<% end -%>
90-
<% if @im_journal_ratelimit_interval and @im_journal_ratelimit_interval != :undef -%>
90+
<% if @im_journal_ratelimit_interval -%>
9191
$imjournalRatelimitInterval <%=@im_journal_ratelimit_interval %>
9292
<% end -%>
93-
<% if @im_journal_ratelimit_burst and @im_journal_ratelimit_burst != :undef -%>
93+
<% if @im_journal_ratelimit_burst -%>
9494
$imjournalRatelimitBurst <%=@im_journal_ratelimit_burst %>
9595
<% end -%>
9696

templates/server-default.conf.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $Template dynDebug,"<%= @server_dir -%>/%source:R,ERE,1,DFLT:([A-Za-z-]*)--end%<
2121
$Template dynMessages,"<%= @server_dir -%>/%source:R,ERE,1,DFLT:([A-Za-z-]*)--end%<%= @logpath -%>messages"
2222

2323
# Rules
24-
<% if @rules and @rules != :undef -%>
24+
<% if @rules -%>
2525
<% @rules.flatten.compact.each do |rules| -%>
2626
<% if rules['selector'] and rules['selector'] != '' and rules['action'] and rules['action'] != '' -%>
2727
<%= rules['selector'] %> <%= rules['action'] %>

templates/server-hostname.conf.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $Template dynDebug,"<%= @server_dir -%>/%hostname%<%= @logpath -%>debug"
1919
$Template dynMessages,"<%= @server_dir -%>/%hostname%<%= @logpath -%>messages"
2020

2121
# Rules
22-
<% if @rules and @rules != :undef -%>
22+
<% if @rules -%>
2323
<% @rules.flatten.compact.each do |rules| -%>
2424
<% if rules['selector'] and rules['selector'] != '' and rules['action'] and rules['action'] != '' -%>
2525
<%= rules['selector'] %> <%= rules['action'] %>

templates/server/_default-header.conf.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ if <%= log_filter['expression'] %> then <%= log_filter['action'] %>
3333
$ActionFileDefaultTemplate <%= @actionfiletemplate %>
3434
<% else -%>
3535

36-
<% if @high_precision_timestamps == false -%>
36+
<% if @high_precision_timestamps -%>
3737
#
38-
# Use traditional timestamp format.
38+
# Use high precision timestamp format.
3939
#
40-
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
40+
$ActionFileDefaultTemplate RSYSLOG_FileFormat
4141
<% else -%>
4242
#
43-
# Use high precision timestamp format.
43+
# Use traditional timestamp format.
4444
#
45-
$ActionFileDefaultTemplate RSYSLOG_FileFormat
45+
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
4646
<% end -%>
4747
<% end -%>
4848

0 commit comments

Comments
 (0)