Commit c83060a7 authored by Tim Smith's avatar Tim Smith Committed by Seth Vargo
Browse files

[COOK-2355] Support forwarding to multiple rsyslog servers


Signed-off-by: default avatarSeth Vargo <sethvargo@gmail.com>
parent 58e80763
......@@ -38,7 +38,7 @@ See `attributes/default.rb` for default values.
* `node['rsyslog']['server']` - Determined automaticaly and set to true on
the server.
* `node['rsyslog']['server_ip']` - If not defined then search will be used
to determine rsyslog server. Default is `nil`.
to determine rsyslog server. Default is `nil`. This can be a string or an array.
* `node['rsyslog']['server_search']` - Specify the criteria for the server
search operation. Default is `role:loghost`.
* `node['rsyslog']['protocol']` - Specify whether to use `udp` or
......@@ -67,9 +67,9 @@ See `attributes/default.rb` for default values.
* `node['rsyslog']['high_precision_timestamps']` - Enable high precision
timestamps, instead of the "old style" format. Default is 'false'.
* `node['rsyslog']['repeated_msg_reduction']` - Value of `$RepeatedMsgReduction`
configuration directive in `/etc/rsyslog.conf`. Default is 'on'
* `node['rsyslog']['logs_to_forward']` - Specifies what logs should be sent to the
remote rsyslog server. Default is all ( \*.\* ).
configuration directive in `/etc/rsyslog.conf`. Default is 'on'
* `node['rsyslog']['logs_to_forward']` - Specifies what logs should be sent to the
remote rsyslog server. Default is all ( \*.\* ).
Recipes
=======
......@@ -192,6 +192,7 @@ License and Author
Author:: Joshua Timberman (<joshua@opscode.com>)
Author:: Denis Barishev (<denz@twiket.com>)
Author:: Tim Smith (<tsmith@limelight.com>)
Copyright:: 2009-2012, Opscode, Inc
......
......@@ -32,10 +32,10 @@ default["rsyslog"]["repeated_msg_reduction"] = "on"
default["rsyslog"]["logs_to_forward"] = "*.*"
# The most likely platform-specific attributes
default["rsyslog"]["service_name"] = "rsyslog"
default["rsyslog"]["user"] = "root"
default["rsyslog"]["group"] = "adm"
default["rsyslog"]["priv_seperation"] = false
default["rsyslog"]["service_name"] = "rsyslog"
default["rsyslog"]["user"] = "root"
default["rsyslog"]["group"] = "adm"
default["rsyslog"]["priv_seperation"] = false
case node["platform"]
when "ubuntu"
......
......@@ -19,23 +19,33 @@
include_recipe "rsyslog"
rsyslog_servers = []
if !node['rsyslog']['server'] and node['rsyslog']['server_ip'].nil? and Chef::Config[:solo]
Chef::Log.fatal("Chef Solo does not support search, therefore it is a requirement of the rsyslog::client recipe that the attribute 'server_ip' is set when using Chef Solo. 'server_ip' is not set.")
elsif !node['rsyslog']['server']
rsyslog_server = node['rsyslog']['server_ip'] ||
search(:node, node['rsyslog']['server_search']).first['ipaddress'] rescue nil
elsif !node['rsyslog']['server']
if node['rsyslog']['server_ip']
# handle node['rsyslog']['server_ip'] being a string or an array
rsyslog_servers = Array(node['rsyslog']['server_ip'])
end
# add all syslog servers to the syslog_servers array
search(:node, node["rsyslog"]["server_search"]) do |result|
syslog_servers << result['ipaddress']
end
if rsyslog_server.nil?
if rsyslog_servers.empty?
Chef::Application.fatal!("The rsyslog::client recipe was unable to determine the remote syslog server. Checked both the server_ip attribute and search()")
end
template "/etc/rsyslog.d/49-remote.conf" do
only_if { node['rsyslog']['remote_logs'] && !rsyslog_server.nil? }
only_if { node['rsyslog']['remote_logs'] && !rsyslog_servers.empty? }
source "49-remote.conf.erb"
backup false
variables(
:server => rsyslog_server,
:protocol => node['rsyslog']['protocol']
:servers => rsyslog_servers,
:protocol => node['rsyslog']['protocol'],
:port => node['rsyslog']['port']
)
mode 0644
notifies :restart, "service[#{node['rsyslog']['service_name']}]"
......
# Autogenerated by Chef for <%= node['fqdn'] %>
<% @servers.each do |server| -%>
<% case @protocol -%>
<% when "tcp" -%>
<%= node['rsyslog']['logs_to_forward'] %> @@<%= @server %>:<%= node['rsyslog']['port'] %>
<%= node['rsyslog']['logs_to_forward'] %> @@<%= @server %>:<%= @port %>
<% when "udp" -%>
<%= node['rsyslog']['logs_to_forward'] %> @<%= @server %>:<%= node['rsyslog']['port'] %>
<%= node['rsyslog']['logs_to_forward'] %> @<%= @server %>:<%= @port %>
<% end -%>
<% end -%>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment