Permalink
Browse files

Merge pull request #4 from pwelch/master

Update cookbook with Foodcritic tests
  • Loading branch information...
2 parents 263ec59 + ddda39a commit 3092a2ac909ae303b8a2ca25cf32635e6fd6ecd9 @mheffner mheffner committed Sep 26, 2012
Showing with 85 additions and 90 deletions.
  1. +57 −0 README.md
  2. +0 −53 README.rdoc
  3. +11 −18 attributes/papertrail.rb
  4. +1 −1 metadata.rb
  5. +16 −18 recipes/default.rb
View
@@ -0,0 +1,57 @@
+
+## DESCRIPTION:
+
+Cookbook to connect syslogging to [papertrailapp.com](https://papertrailapp.com/).
+
+## REQUIREMENTS:
+
+ * [rsyslog cookbook](http://community.opscode.com/cookbooks/rsyslog)
+
+## INSTALLATION
+
+The easiest way to install this is to use [knife-github-cookbooks](https://github.com/websterclay/knife-github-cookbooks):
+
+ gem install knife-github-cookbooks
+ knife github cookbook install librato/papertrail-cookbook
+
+## ATTRIBUTES:
+
+```ruby
+node['papertrail']['logger'] - Logger to use. Support loggers include: rsyslog. Defaults to rsyslog.
+
+node['papertrail']['remote_host'] - Papertrail host to send stats to. Defaults to 'logs.papertrailapp.com'.
+
+node['papertrail']['remote_port'] - Port to use. No default.
+
+node['papertrail']['cert_file'] - Where to store papertrail cert file..
+
+node['papertrail']['cert_url'] - URL to download certificate from.
+```
+
+By default, this recipe will log to Papertrail using the system's
+hostname. If you want to set the hostname that will be used (think
+ephemeral cloud nodes) you can set one of the following. If either is
+set it will use the hostname_name first and the hostname_cmd second.
+
+node['papertrail']['hostname_name'] - Set the logging hostname to this string.
+
+node['papertrail']['hostname_cmd'] - Set the logging hostname to the
+output of this command passed to system(). This is useful if the
+desired hostname comes from a dynamic source like EC2 meta-data.
+
+File monitoring is not really a part of papertrail but is included here:
+
+node['papertrail']['watch_files'] - This is a hash of files and associated tags
+that will be configured to be watched and included in the papertrail logging.
+This is useful for including output from applications that aren't configured
+to use syslog. Example:
+
+ {
+ '/var/log/chef/client.log' => 'chef',
+ '/var/log/something_else.log' => 'tag'
+ }
+
+## USAGE:
+
+Include the default recipe in your chef run list.
+
View
@@ -1,53 +0,0 @@
-= DESCRIPTION:
-
-Cookbook to connect syslogging to papertrailapp.com.
-
-= REQUIREMENTS:
-
- * rsyslog cookbook
-
-= INSTALLATION
-
-The easiest way to install this is to use {knife-github-cookbooks}[https://github.com/websterclay/knife-github-cookbooks]:
-
- gem install knife-github-cookbooks
- knife github cookbook install librato/papertrail-cookbook
-
-= ATTRIBUTES:
-
-node[:papertrail][:logger] - Logger to use. Support loggers include: rsyslog. Defaults to rsyslog.
-
-node[:papertrail][:remote_host] - Papertrail host to send stats to. Defaults to 'logs.papertrailapp.com'.
-
-node[:papertrail][:remote_port] - Port to use. No default.
-
-node[:papertrail][:cert_file] - Where to store papertrail cert file..
-
-node[:papertrail][:cert_url] - URL to download certificate from.
-
-By default, this recipe will log to Papertrail using the system's
-hostname. If you want to set the hostname that will be used (think
-ephemeral cloud nodes) you can set one of the following. If either is
-set it will use the hostname_name first and the hostname_cmd second.
-
-node[:papertrail][:hostname_name] - Set the logging hostname to this string.
-
-node[:papertrail][:hostname_cmd] - Set the logging hostname to the
-output of this command passed to system(). This is useful if the
-desired hostname comes from a dynamic source like EC2 meta-data.
-
-File monitoring is not really a part of papertrail but is included here:
-
-node[:papertrail][:watch_files] - This is a hash of files and associated tags
-that will be configured to be watched and included in the papertrail logging.
-This is useful for including output from applications that aren't configured
-to use syslog. Example:
-
- {
- '/var/log/chef/client.log' => 'chef',
- '/var/log/something_else.log' => 'tag'
- }
-
-= USAGE:
-
-Just include the default recipe.
@@ -1,53 +1,46 @@
# Logger to use. Support loggers include: rsyslog.
-#
-default[:papertrail][:logger] = "rsyslog"
+default['papertrail']['logger'] = "rsyslog"
# Papertrail host to send stats to.
-#
-default[:papertrail][:remote_host] = "logs.papertrailapp.com"
+default['papertrail']['remote_host'] = "logs.papertrailapp.com"
# Port to use. MUST be set
# XXX: should pull from a databag since this is private
-#
-default[:papertrail][:remote_port] = nil
+default['papertrail']['remote_port'] = nil
# Where to store papertrail cert file.
-#
-default[:papertrail][:cert_file] = "/etc/papertrail.crt"
+default['papertrail']['cert_file'] = "/etc/papertrail.crt"
# URL to download certificate from.
-#
-default[:papertrail][:cert_url] = "https://papertrailapp.com/tools/syslog.papertrail.crt"
+default['papertrail']['cert_url'] = "https://papertrailapp.com/tools/syslog.papertrail.crt"
# By default, this recipe will log to Papertrail using the system's
# hostname. If you want to set the hostname that will be used (think
# ephemeral cloud nodes) you can set one of the following. If either is
# set it will use the hostname_name first and the hostname_cmd second.
# Set the logging hostname to this string.
-#
-default[:papertrail][:hostname_name] = ""
+default['papertrail']['hostname_name'] = ""
# Set the logging hostname to the output of this command passed to
# system(). This is useful if the desired hostname comes from a
# dynamic source like EC2 meta-data.
-#
-default[:papertrail][:hostname_cmd] = ""
+default['papertrail']['hostname_cmd'] = ""
# File monitoring is not really a part of papertrail but is included here:
#
-# default[:papertrail][:watch_files] - This is a list of files that will be
+# default['papertrail']['watch_files'] - This is a list of files that will be
# configured to be watched and included in the papertrail logging. This
# is useful for including output from applications that aren't
# configured to use syslog. Each entry in this list is a hash of:
#
-# [:filename] - Full path to the file.
-# [:tag] - What to tag log lines that come from this file. Best to
+# ['filename'] - Full path to the file.
+# ['tag'] - What to tag log lines that come from this file. Best to
# use a short application name.
#
# For example:
#
-# node[:papertrail][:watch_files] =
+# node['papertrail']['watch_files'] =
# [{:filename => "/var/log/myapp.log", :tag => "myapp:"}]
#
View
@@ -2,7 +2,7 @@
maintainer_email "mike@librato.com"
license "Apache 2.0"
description "Installs/Configures Sys Logging to papertrailapp.com"
-long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.3"
depends "rsyslog"
View
@@ -17,7 +17,7 @@
# limitations under the License.
##
-return unless node[:papertrail][:logger] == "rsyslog"
+return unless node['papertrail']['logger'] == "rsyslog"
syslogger = "rsyslog"
@@ -30,22 +30,21 @@
not_if {File.exists?("/usr/lib/rsyslog/lmnsd_gtls.so")}
end
-remote_file node[:papertrail][:cert_file] do
- source node[:papertrail][:cert_url]
+remote_file node['papertrail']['cert_file'] do
+ source node['papertrail']['cert_url']
mode "0444"
end
syslogdir = "/etc/rsyslog.d"
-if node[:papertrail][:watch_files] && node[:papertrail][:watch_files].length > 0
-
+if node['papertrail']['watch_files'] && node['papertrail']['watch_files'].length > 0
watch_file_array = []
- if node[:papertrail][:watch_files].respond_to?(:keys)
+ if node['papertrail']['watch_files'].respond_to?(:keys)
require 'digest/sha1'
- node[:papertrail][:watch_files].each do |filename, tag|
+ node['papertrail']['watch_files'].each do |filename, tag|
watch_file_array << {
:filename => filename,
:tag => tag,
@@ -56,14 +55,13 @@
# Sort to preserve order of the config
watch_file_array = watch_file_array.sort { |a,b| a[:filename] <=> b[:filename] }
- elsif node[:papertrail][:watch_files].is_a?(Array)
+ elsif node['papertrail']['watch_files'].is_a?(Array)
# Deprecate but retain backwards compatibility
- Chef::Log.info "DEPRECATION WARNING: Please convert this node's [:papertrail][:watch_files] attribute from an Array to a Hash"
+ Chef::Log.info "DEPRECATION WARNING: Please convert this node's ['papertrail']['watch_files'] attribute from an Array to a Hash"
Chef::Log.info " to allow use of override_attribtutes for addition of watch_files"
- watch_file_array = node[:papertrail][:watch_files]
-
+ watch_file_array = node['papertrail']['watch_files']
end
template "#{syslogdir}/60-watch-files.conf" do
@@ -76,11 +74,11 @@
end
end
-hostname_name = node[:papertrail][:hostname_name].to_s
-hostname_cmd = node[:papertrail][:hostname_cmd].to_s
+hostname_name = node['papertrail']['hostname_name'].to_s
+hostname_cmd = node['papertrail']['hostname_cmd'].to_s
unless hostname_name.empty? && hostname_cmd.empty?
- node[:papertrail][:fixhostname] = true
+ node['papertrail']['fixhostname'] = true
if !hostname_name.empty?
name = hostname_name
@@ -103,10 +101,10 @@
owner "root"
group "root"
mode "0644"
- variables({ :cert_file => node[:papertrail][:cert_file],
- :host => node[:papertrail][:remote_host],
- :port => node[:papertrail][:remote_port],
- :fixhostname => node[:papertrail][:fixhostname]
+ variables({ :cert_file => node['papertrail']['cert_file'],
+ :host => node['papertrail']['remote_host'],
+ :port => node['papertrail']['remote_port'],
+ :fixhostname => node['papertrail']['fixhostname']
})
notifies :restart, resources(:service => syslogger)
end

0 comments on commit 3092a2a

Please sign in to comment.