summaryrefslogtreecommitdiff
path: root/manifests/database.pp
blob: 8046d2aa9835f7e99bbf306b39d7cd7508feb3df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# == Class: rsyslog::database
#
# Full description of class role here.
#
# === Parameters
#
# [*backend*]  - Which backend server to use (mysql|pgsql)
# [*server*]   - Server hostname
# [*database*] - Database name
# [*username*] - Database username
# [*password*] - Database password
#
# === Variables
#
# === Examples
#
#  class { 'rsyslog::database':
#    backend  => 'mysql',
#    server   => 'localhost',
#    database => 'mydb',
#    username => 'myuser',
#    password => 'mypass',
#  }
#
class rsyslog::database (
  $backend,
  $server,
  $database,
  $username,
  $password
) inherits rsyslog {

  $db_module = "om${backend}"
  $db_conf = "${rsyslog::params::rsyslog_d}${backend}.conf"

  case $backend {
    mysql: { $db_package = $rsyslog::params::mysql_package_name }
    pgsql: { $db_package = $rsyslog::params::pgsql_package_name }
    default: { fail("Unsupported backend: ${backend}. Only MySQL (mysql) and PostgreSQL (pgsql) are supported.") }
  }

  package { $db_package:
    ensure => $rsyslog::params::package_status,
    before => File[$db_conf],
  }

  file { $db_conf:
    ensure  => present,
    owner   => 'root',
    group   => $rsyslog::params::run_group,
    mode    => '0600',
    content => template("${module_name}/database.conf.erb"),
    require => Class['rsyslog::config'],
    notify  => Class['rsyslog::service'],
  }
}