rsyslog.pp 3.8 KB
Newer Older
1
2
3
4
##############################################################################
# Create rsyslog.conf
##############################################################################
#
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# This define is used by the base::syslog module.  It is not execpted
# to be used directly, but the actions of base::syslog overridden as
# needed.
#
# The use_ variables allow for the following transitions.
#
#  1. From an rsyslog configuration that pulls in an old syslog.conf
#     to a configuration that is all rsyslog and uses rsyslog
#     fragments.
#
#  2. From v5 to v7 of rsyslog.  To use the default v7 configuration
#     the syslog.conf transition must be complete.
#
# Example:
#
#  This example uses the default rsyslog version 7 configuration.
#
#  class s_ldap::conf::syslog-dev inherits base::syslog {
#    Base::Syslog::Config::Rsyslog['/etc/rsyslog.conf'] {
#      use_syslog_conf => false,
#      use_v5          => false,
#    }
#  }
28
29
30
31
32
33
34
35
36
37
#
# Note: There are situations where puppet does not process booleans
# correctly.  Specifically this was found to be the case with the
# use_syslog_conf variable.  Because of this it might be necessary to
# specify use_syslog_conf as a string, for example:
#
#   use_syslog_conf = 'true'
#
# The perferred method is to use a boolean, but if that does not work
# use a string value.
Adam Lewenberg's avatar
Adam Lewenberg committed
38
39

define base::syslog::config::rsyslog(
40
41
42
43
44
  $ensure          = 'present',
  $source          = undef,
  $owner           = 'root',
  $group           = 'root',
  $mode            = '0644',
45
  $syslog_server   = 'logsink.stanford.edu',
46
  $replace         = true,
47
  $use_syslog_conf = false,
48
  $use_default     = true,
49
  $use_v5          = false,
Adam Lewenberg's avatar
Adam Lewenberg committed
50
) {
51

52
53
  if ($use_syslog_conf != 'true' and $use_syslog_conf != true) {
    if ($use_v5 == 'true' or $use_v5 == true) {
54
55
56
57
58
      $rsyslog_tmpl = 'etc/rsyslog.d/20-templates-v5.conf'
      $rsyslog_def  = 'etc/rsyslog.d/95-default-v5.conf.erb'
    } else {
      $rsyslog_tmpl = 'etc/rsyslog.d/20-templates.conf'
      $rsyslog_def  = 'etc/rsyslog.d/95-default.conf.erb'
59
      # Warn if trying to use v7 in the wrong place
60
61
62
      case $::operatingsystem {
        'debian', 'ubuntu': {
          case $::lsbdistcodename {
63
            'lenny', 'squeeze': {
64
              fail('rsyslog v7 not supported on squeeze or lenny')
65
66
67
68
            }
          }
        }
      }
69
    }
70
71
72
73
74
75
76
77
78
79
    # Always install templates.  They can be ignore if there are
    # not useful.
    file { '/etc/rsyslog.d/20-templates.conf':
      ensure  => present,
      source  => "puppet:///modules/base/syslog/$rsyslog_tmpl",
      owner   => $owner,
      group   => $group,
      mode    => $mode,
      notify  => Service['syslog'],
    }
80
81
82
83
84
85
86
87
88
89
    # Make sure there is a directory to hold disk based queues.
    # This directory is specified in the rsyslog configuration
    # with the $WorkDirectory directive.
    file { '/var/lib/rsyslog_queue':
      ensure  => directory,
      owner   => $owner,
      group   => $group,
      notify  => Service['syslog'],
    }

90
    # Install the default catch all rule, or not, as desired.
91
    if ($use_default == 'true' or $use_default == true){
92
93
94
95
96
97
98
      file { '/etc/rsyslog.d/95-default.conf':
        ensure  => present,
        content => template("base/syslog/$rsyslog_def"),
        owner   => $owner,
        group   => $group,
        mode    => $mode,
        notify  => Service['syslog'],
99
100
      }
    } else {
101
102
103
      file { '/etc/rsyslog.d/95-default.conf':
        ensure  => absent,
        notify  => Service['syslog'],
104
      }
105
    }
Adam Lewenberg's avatar
Adam Lewenberg committed
106
  }
107

108
  # Template for the base rsyslog configuration.
109
  if $source {
110
111
112
113
    $template = undef
  } else {
    $template = template('base/syslog/rsyslog.conf.erb')
  }
Adam Lewenberg's avatar
Adam Lewenberg committed
114
115
116
117
118
119
120
121
122
123
  file { $name:
    ensure  => $ensure,
    source  => $source,
    content => $template,
    owner   => $owner,
    group   => $group,
    mode    => $mode,
    replace => $replace,
    notify  => Service['syslog'],
  }
124
}