Created
January 26, 2011 22:12
-
-
Save jbz/797595 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from rsyslog::default.rb: | |
service "rsyslog" do | |
supports :restart => true, :reload => true | |
action [:enable, :start] | |
end | |
# from rsyslog/providers/imfile.rb: | |
# Create new rsyslog snippet to configure imfile to follow a text log | |
action :create do | |
service "rsyslog" do | |
supports :restart => true, :reload => true | |
action :nothing | |
end | |
template "/etc/rsyslog.d/#{new_resource.tag}.conf" do | |
source "imfile-stanza.erb" | |
cookbook "rsyslog" | |
owner "root" | |
group "root" | |
mode 0644 | |
variables( | |
:location => new_resource.location, | |
:tag => new_resource.tag, | |
:facility => new_resource.facility, | |
:priority => new_resource.priority, | |
:label => new_resource.label) | |
notifies :reload, "service[rsyslog]", :delayed | |
end | |
end | |
# Remove any rsyslog snippets for the named tag | |
action :delete do | |
file "/etc/rsyslog.d/#{new_resource.tag}.conf" do | |
only_if "test -f /etc/rsyslog.d/#{new_resource.tag}.conf" | |
action :delete | |
# notifies :reload, "service[rsyslog]", :delayed | |
end | |
end | |
# From rsyslog/resources/textlog.rb: | |
actions :create, :delete | |
attribute :location, :required => true, :kind_of => String | |
attribute :tag, :required => true | |
attribute :facility, :kind_of => String | |
attribute :priority, :kind_of => String | |
attribute :label, :kind_of => String | |
# From the calling cookbook: | |
# Set up textfile logging for the main nginx error log | |
rsyslog_textlog "nginx-error" do | |
location "/opt/nginx/logs/error.log" | |
tag "nginx-main-error" | |
facility "user" | |
priority "err" | |
label "main nginx error log" | |
action :create | |
provider "rsyslog_imfile" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment