Added syslog::standalone class. Still missing log rotation.

This commit is contained in:
Timo Mkinen 2011-08-30 17:56:53 +03:00
parent c3d5784660
commit 94c961688e
2 changed files with 112 additions and 0 deletions

View file

@ -108,3 +108,112 @@ class syslog::client::rsyslog {
}
}
# Install standalone syslog client
#
# === Global variables:
#
# $syslog_type:
# Syslog type to use. Valid values are syslogd and rsyslog.
# Default depends on operating system.
#
# $syslog_datadir:
# Directory where to store logs. Defaults to /srv/log.
#
class syslog::standalone {
if !$syslog_type {
case $operatingsystem {
"centos": { $syslog_type = "syslogd" }
"fedora": { $syslog_type = "rsyslog" }
"openbsd": { $syslog_type = "syslogd" }
"ubuntu": { $syslog_type = "rsyslog" }
}
}
if $syslog_datadir {
file { $syslog_datadir:
ensure => directory,
mode => 0750,
owner => "root",
group => $operatingsystem ? {
"openbsd" => "wheel",
default => "root",
},
}
file { "/srv/log":
ensure => link,
target => $syslog_datadir,
owner => "root",
group => $operatingsystem ? {
"openbsd" => "wheel",
default => "root",
},
require => File[$syslog_datadir],
}
} else {
file { "/srv/log":
ensure => directory,
mode => 0755,
owner => "root",
group => $operatingsystem ? {
"openbsd" => "wheel",
default => "root",
},
}
}
file { "/srv/log/archive":
ensure => directory,
mode => 0755,
owner => "root",
group => $operatingsystem ? {
"openbsd" => "wheel",
default => "root",
},
require => File["/srv/log"],
}
file { "/var/log/all.log":
ensure => link,
target => "/srv/log/all.log",
}
case $syslog_type {
"syslogd": { include syslog::standalone::syslogd }
"rsyslog": { include syslog::standalone::rsyslog }
default: { fail("Unknown \$syslog_type '$syslog_type'") }
}
}
# Install standalone syslog host using syslogd.
#
class syslog::standalone::syslogd inherits syslog::client::syslogd {
File["/etc/syslog.conf"] {
content => template("syslog/syslog.conf.$operatingsystem.erb",
"syslog/syslog.conf.server.erb"),
require => [ File["/srv/log"],
File["/var/log/all.log"], ],
}
}
# Install standalone syslog host using rsyslog.
#
class syslog::standalone::rsyslog inherits syslog::client::rsyslog {
File["/etc/rsyslog.conf"] {
content => template("syslog/rsyslog.conf.erb",
"syslog/syslog.conf.$operatingsystem.erb",
"syslog/syslog.conf.server.erb"),
require => [ File["/srv/log"],
File["/var/log/all.log"], ],
}
}

View file

@ -0,0 +1,3 @@
*.* /srv/log/all.log
mark.* /srv/log/all.log