Puppet Class: bacula::director::config::postgresql

Defined in:
manifests/director/config/postgresql.pp

Overview

Class: bacula::director::config::postgresql

Configure the Bacula database on postgresql server. Currently only supports Debian (and possibly Ubuntu).

Parameters:

  • postgresql_auth_line (Any)
  • bacula_db_password (Any)


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
58
59
60
61
62
63
64
65
66
67
68
69
# File 'manifests/director/config/postgresql.pp', line 7

class bacula::director::config::postgresql
(
    $postgresql_auth_line,
    $bacula_db_password
)
{
    include ::postgresql::params

    # Prepare postgresql for Bacula's own database schema scripts
    postgresql::loadsql { 'bacula-bacula-director.sql':
        modulename => 'bacula',
        basename   => 'bacula-director',
        require    => Class['::postgresql::install'],
    }

    $script_dir = $::bacula::params::script_dir

    # FIXME: neither of the two following Execs seem to get run during initial
    # install. The reason could be the "refreshonly" parameter: the first
    # Puppet run almost never works, and if the Execs are loaded then, they
    # will not be loaded again later, when they could actually do some good.
    # At this point this is just pure speculation, but the problem itself has
    # been encountered on every Bacula install so far.

    Exec {
        cwd         => $script_dir,
        path        => [ '/usr/bin' ],
        user        => 'postgres',
        refreshonly => true,
        subscribe   => Postgresql::Loadsql['bacula-bacula-director.sql'],
    }

    exec { 'bacula-make_postgresql_tables':
        environment => [ 'db_name=bacula' ],
        command     => "${script_dir}/make_postgresql_tables",
        require     => Postgresql::Loadsql['bacula-bacula-director.sql'],
    }

    exec { 'bacula-grant_postgresql_privileges':
        environment => [ 'db_name=bacula', 'db_user=baculauser' ],
        command     => "${script_dir}/grant_postgresql_privileges",
        require     => Exec['bacula-make_postgresql_tables'],
    }

    # Add an authentication line for baculauser to postgresql pg_hba.conf. For 
    # details look into postgresql::config class.
    augeas { 'bacula-director-pg_hba.conf':
        context => "/files${::postgresql::params::pg_hba_conf}",
        changes => [
            'ins 0434 after 1',
            'set 0434/type local',
            'set 0434/database bacula',
            'set 0434/user baculauser',
            'set 0434/method password'
        ],
        lens    => 'Pg_hba.lns',
        incl    => $::postgresql::params::pg_hba_conf,
        # Without "onlyif" every Puppet run would generate a new authentication 
        # line to pg_hba.conf.
        onlyif  => "match *[user = 'baculauser'] size == 0",
        notify  => Class['postgresql::service'],
    }
}