Commit 96474d48 authored by jtimberman's avatar jtimberman
Browse files

COOK-73, search method for fqdn, protocol attribute, rsyslog.d files

The 'first' method caused typeerror and no method was a nilclass error,
so the search for fqdn uses map block, per the recipes search on the wiki.

Added protocol selection support, UDP vs TCP.

Handle rsyslog.d files - delete client remote.conf on the server and
server.conf on the client.

Updated README.
parent e21ddfd5
......@@ -14,6 +14,7 @@ Tested on Ubuntu 8.10.
* rsyslog[:log_dir] - specify the directory to store logs (applicable to server only)
* rsyslog[:server] - specify the remote rsyslog server.
* rsyslog[:protocol] - specify whether to use udp or tcp for remote log transmission. tcp is default.
= USAGE:
......@@ -25,10 +26,16 @@ To set up a client with a remote [r]syslog server:
include_recipe "rsyslog::client"
Note, the remote server must support syslog on TCP, so set up a server with:
By default, this cookbook will use TCP so the server should be configured for TCP. This can be done easily with the server recipe:
include_recipe "rsyslog::server"
To switch to UDP, change the rsyslog[:protocol] attribute. Note this needs to be done on each client as well.
Also, the server configuration will set up log_dir for each client, by date. Structure:
<%= @log_dir %>/YEAR/MONTH/DAY/HOSTNAME/"logfile"
= LICENSE and AUTHOR:
Author:: Joshua Timberman (<joshua@opscode.com>)
......
......@@ -21,3 +21,4 @@ rsyslog Mash.new unless attribute?("rsyslog")
rsyslog[:log_dir] = "/srv/rsyslog" unless rsyslog.has_key?(:log_dir)
rsyslog[:server] = false unless rsyslog.has_key?(:server)
rsyslog[:protocol] = "tcp" unless rsyslog.has_key?(:protocol)
\ No newline at end of file
......@@ -19,13 +19,20 @@
include_recipe "rsyslog"
rsyslog_server = node[:rsyslog][:server] ? node[:rsyslog][:server] : search(:node, "recipe:rsyslog::server").first["fqdn"]
rsyslog_server = node[:rsyslog][:server] ? node[:rsyslog][:server] : search(:node, "recipe:rsyslog::server").map { |n| n["fqdn"] }
template "/etc/rsyslog.d/remote.conf" do
source "remote.conf.erb"
variables :server => rsyslog_server
backup false
variables :server => rsyslog_server, :protocol => node[:rsyslog][:protocol]
owner "root"
group "root"
mode 0644
notifies :restart, resources(:service => "rsyslog"), :delayed
end
file "/etc/rsyslog.d/server.conf" do
action :delete
notifies :reload, resources(:service => "rsyslog"), :delayed
only_if do File.exists?("/etc/rsyslog.d/server.conf") end
end
......@@ -27,13 +27,20 @@ end
template "/etc/rsyslog.d/server.conf" do
source "server.conf.erb"
variables :log_dir => node[:rsyslog][:log_dir]
backup false
variables :log_dir => node[:rsyslog][:log_dir], :protocol => node[:rsyslog][:protocol]
owner "root"
group "root"
mode 0755
mode 0644
notifies :restart, resources(:service => "rsyslog"), :delayed
end
file "/etc/rsyslog.d/remote.conf" do
action :delete
notifies :reload, resources(:service => "rsyslog"), :delayed
only_if do File.exists?("/etc/rsyslog.d/remote.conf") end
end
cron "rsyslog_gz" do
minute "0"
hour "4"
......
*.* @@<%= @server -%>
<% case @protocol -%>
<% when "tcp" -%>
*.* @@<%= @server %>
<% when "udp" -%>
*.* @<%= @server %>
<% end -%>
# Generated by Chef.
# Local modifications will be overwritten.
<% case @protocol -%>
<% when "tcp" -%>
$ModLoad imtcp
$InputTCPServerRun 514
<% when "udp" -%>
$ModLoad imudp
$UDPServerRun 514
<% end -%>
$DirGroup root
$DirCreateMode 0755
......
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