summaryrefslogtreecommitdiffstats
path: root/lib/puppet/provider/syslog
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-08-05 19:04:41 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-08-05 19:04:41 +0000
commit1e6c2baffb7605da2bc40a0a49c267c51a54a056 (patch)
tree1ecc2b9f1aec3789ffecf5406d90d80b01257a9c /lib/puppet/provider/syslog
parent22e7b390878769e2079b5bbd5f10ab152b4b921d (diff)
downloadpuppet-1e6c2baffb7605da2bc40a0a49c267c51a54a056.tar.gz
puppet-1e6c2baffb7605da2bc40a0a49c267c51a54a056.tar.xz
puppet-1e6c2baffb7605da2bc40a0a49c267c51a54a056.zip
Adding syslog support by devdas (#745).
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2748 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/provider/syslog')
-rw-r--r--lib/puppet/provider/syslog/parsed.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/puppet/provider/syslog/parsed.rb b/lib/puppet/provider/syslog/parsed.rb
new file mode 100644
index 000000000..9904c673a
--- /dev/null
+++ b/lib/puppet/provider/syslog/parsed.rb
@@ -0,0 +1,40 @@
+require 'puppet/provider/parsedfile'
+
+# The default target
+# We should be able to override this by setting it explicitly in Facter
+case Facter.value(:syslogconf)
+when nil:
+ syslogconf = "/etc/syslog.conf"
+else
+ syslogconf = Facter.value(:syslogconf)
+end
+
+Puppet::Type.type(syslog).provide(:parsed,
+ :parent => Puppet::Provider::ParsedFile,
+ :default_target => syslogconf,
+ :filetype => :flat
+) do
+text_line :comment, :match => /^#/
+text_line :blank, :match => /^\s+/
+
+record_line :parsed, :fields => %w{source target},
+ :post_parse => proc { |hash|
+ if hash[:source] =~ /;/
+ sources = hash[:source].split(";");
+ sources.each { |level|
+ if level[:facility] =~ /\./
+ names = level[:facility].split("\.")
+ hash[:facility] = names.shift
+ hash[:priority] = names
+ end
+ }
+ end
+ }
+ :pre_gen => proc { |hash|
+ if hash[:alias]
+ names = [hash[:name], hash[:alias]].flatten
+ hash[:name] = [hash[:name], hash[:alias]].flatten.join(",")
+ hash.delete(:alias)
+ end
+ }
+end