From bb1ebee33e2f6af009992a142e62762189b0e177 Mon Sep 17 00:00:00 2001 From: Greig McGill Date: Thu, 14 Jul 2016 19:34:27 +1200 Subject: [PATCH] Clarify README example and add basic spec test for log_server entries with port values. --- README.md | 3 ++- spec/classes/init_spec.rb | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e3e1935..16b1ec9 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,7 @@ Transport protocol used by rsyslog. Valid values are 'tcp' and 'udp' log_server ---------- -String or array of server to send logs to if remote_logging is true. +String or array of server to send logs to if remote_logging is true. May include an optional port number if you wish to override the log_server_port value for an entry. *Example:*
@@ -346,6 +346,7 @@ _OR_
 rsyslog::log_server:
   - 'log1'
   - 'log2:1514'
+  - 'log3:2514'
 
- *Default*: "log.${::domain}" diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 9f111e1..baf7970 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -250,7 +250,7 @@ it { should contain_file('rsyslog_config').without_content(/^\$ModLoad imtcp.so$/) } end - ['logserver', %w(logserver1 logserver2)].each do |values| + ['logserver', %w(logserver1 logserver2 logserver3:1514 logserver4:2514)].each do |values| context "with remote_logging enabled and log_server=#{values} (as #{values.class})" do let :params do { @@ -261,7 +261,11 @@ if values.class == Array values.each do |value| - it { should contain_file('rsyslog_config').with_content(/^\*\.\* @@#{value}:514$/) } + if value.include? ":" + it { should contain_file('rsyslog_config').with_content(/^\*\.\* @@#{value}$/) } + else + it { should contain_file('rsyslog_config').with_content(/^\*\.\* @@#{value}:514$/) } + end end else it { should contain_file('rsyslog_config').with_content(/^\*\.\* @@logserver:514$/) }