Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow logserver entries to include port numbers, with log_server_port only used if a port isn't specified. #115

Merged
merged 1 commit into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:*
<pre>
Expand All @@ -345,14 +345,15 @@ _OR_
<pre>
rsyslog::log_server:
- 'log1'
- 'log2'
- 'log2:1514'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an explanation for this in the message above on line 338

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, that was a typo anyway, it should have been log3 - implying a third log server destination using a non-default port.

- 'log3:2514'
</pre>

- *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'

Expand Down
8 changes: 6 additions & 2 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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$/) }
Expand Down
4 changes: 4 additions & 0 deletions templates/rsyslog.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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' -%>
Expand Down