summaryrefslogtreecommitdiff
path: root/manifests/database.pp
blob: fe6d6ac87e0500568e587ef0764358ec50925e2f (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
57
# == 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::rsyslog_d}${backend}.conf"

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

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

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

}