# Install syslog client # # === Global variables: # # $syslog_type: # Syslog type to use. Valid values are syslogd and rsyslog. # Default depends on operating system. # # $syslog_server: # Address of remote syslog server where to send logs. # class syslog::client { if !$syslog_type { case $operatingsystem { "centos": { $syslog_type = "syslogd" } "fedora": { $syslog_type = "rsyslog" } "openbsd": { $syslog_type = "syslogd" } "ubuntu": { $syslog_type = "rsyslog" } } } case $syslog_type { "syslogd": { include syslog::client::syslogd } "rsyslog": { include syslog::client::rsyslog } default: { fail("Unknown \$syslog_type '$syslog_type'") } } } # Install syslog client using syslogd # class syslog::client::syslogd { if $operatingsystem != "OpenBSD" { package { "syslogd": name => "sysklogd", ensure => installed, before => File["/etc/syslog.conf"], } } file { "/etc/syslog.conf": ensure => present, content => template("syslog/syslog.conf.$operatingsystem.erb", "syslog/syslog.conf.client.erb"), mode => 0644, owner => "root", group => $operatingsystem ? { "openbsd" => "wheel", default => "root", }, notify => Service["syslogd"], } service { "syslogd": name => $operatingsystem ? { "openbsd" => "syslogd", default => "syslog", }, ensure => running, enable => true, start => $operatingsystem ? { "openbsd" => "syslogd -a /var/www/dev/log -a /var/named/dev/log -a /var/empty/dev/log", default => undef, }, restart => $operatingsystem ? { "openbsd" => "pkill -HUP -u _syslogd", default => undef, }, } } # Install syslog client using rsyslog. # class syslog::client::rsyslog { package { "rsyslog": ensure => installed, } file { "/etc/rsyslog.conf": ensure => present, content => template("syslog/rsyslog.conf.erb", "syslog/syslog.conf.$operatingsystem.erb", "syslog/syslog.conf.client.erb"), mode => 0644, owner => "root", group => $operatingsystem ? { "openbsd" => "wheel", default => "root", }, require => Package["rsyslog"], notify => Service["rsyslog"], } service { "rsyslog": ensure => running, enable => true, start => $operatingsystem ? { "openbsd" => "pkill syslogd ; /usr/local/sbin/rsyslogd -c 4 -x -i /var/run/syslog.pid", default => undef, }, } } # 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"], ], } }