diff --git a/README.md b/README.md index fd33b45..a1e878d 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:*
@@ -345,14 +345,15 @@ _OR_rsyslog::log_server: - 'log1' - - 'log2' + - 'log2:1514' + - 'log3:2514'- *Default*: "log.${::domain}" log_server_port --------------- -Port of the server to send logs to if remote_logging is true. +Default port of the server to send logs to if remote_logging is true. Will not be used if a log_server entry contains a port number. - *Default*: '514' diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 542af86..5534eee 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$/) } 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$/) } diff --git a/templates/rsyslog.conf.erb b/templates/rsyslog.conf.erb index 298c0f8..0e32744 100644 --- a/templates/rsyslog.conf.erb +++ b/templates/rsyslog.conf.erb @@ -106,9 +106,13 @@ $ActionQueueType LinkedList # run asynchronously $ActionResumeRetryCount -1 # infinite retries if host is down <% end -%> <% @log_server_real.each do |server| -%> +<% if server.include? ":" -%> +<%= @source_facilities %> <% if @transport_protocol == 'tcp' -%>@<% end -%>@<%= server %> +<% else -%> <%= @source_facilities %> <% if @transport_protocol == 'tcp' -%>@<% end -%>@<%= server -%>:<%= @log_server_port %> <% end -%> <% end -%> +<% end -%> <% if @rsyslog_conf_version_real > 2 -%> <% if @is_log_server_real.to_s == 'true' -%>