Puppet Class: postgresql::master

Defined in:
modules/postgresql/manifests/master.pp

Overview

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • master_server (Stdlib::Host) (defaults to: $facts['fqdn'])
  • includes (Array[String]) (defaults to: [])
  • max_wal_senders (Integer) (defaults to: 5)
  • checkpoint_segments (Integer) (defaults to: 64)
  • wal_keep_segments (Integer) (defaults to: 128)
  • root_dir (Stdlib::Unixpath) (defaults to: '/var/lib/postgresql')
  • use_ssl (Boolean) (defaults to: false)
  • locale (String) (defaults to: 'en_US.UTF-8')
  • sync_count (Integer) (defaults to: 1)
  • sync_mode (String) (defaults to: 'on')
  • log_line_prefix (String) (defaults to: '%t ')
  • ssldir (Optional[Stdlib::Unixpath]) (defaults to: undef)
  • sync_replicas (Optional[Array[String]]) (defaults to: undef)
  • log_min_duration_statement (Optional[Integer[250]]) (defaults to: undef)
  • log_autovacuum_min_duration (Optional[Integer]) (defaults to: undef)
  • pgversion (Optional[Numeric]) (defaults to: undef)


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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'modules/postgresql/manifests/master.pp', line 37

class postgresql::master(
    Wmflib::Ensure             $ensure                      = 'present',
    Stdlib::Host               $master_server               = $facts['fqdn'],
    Array[String]              $includes                    = [],
    Integer                    $max_wal_senders             = 5,
    Integer                    $checkpoint_segments         = 64,
    Integer                    $wal_keep_segments           = 128,
    Stdlib::Unixpath           $root_dir                    = '/var/lib/postgresql',
    Boolean                    $use_ssl                     = false,
    String                     $locale                      = 'en_US.UTF-8',
    Integer                    $sync_count                  = 1,
    String                     $sync_mode                   = 'on',
    String                     $log_line_prefix             = '%t ',
    Optional[Stdlib::Unixpath] $ssldir                      = undef,
    Optional[Array[String]]    $sync_replicas               = undef,
    Optional[Integer[250]]     $log_min_duration_statement  = undef,
    Optional[Integer]          $log_autovacuum_min_duration = undef,
    Optional[Numeric]          $pgversion                   = undef,
) {

    $_pgversion = $pgversion ? {
        undef   => debian::codename() ? {
            'stretch'  => 9.6,
            'buster'   => 11,
            'bullseye' => 13,
            default    => fail("${title} not supported by: ${debian::codename()})")
        },
        default => $pgversion,
    }
    $data_dir = "${root_dir}/${_pgversion}/main"

    class { 'postgresql::server':
        ensure                      => $ensure,
        pgversion                   => $_pgversion,
        includes                    => $includes + ['master.conf'],
        root_dir                    => $root_dir,
        use_ssl                     => $use_ssl,
        ssldir                      => $ssldir,
        log_line_prefix             => $log_line_prefix,
        log_min_duration_statement  => $log_min_duration_statement,
        log_autovacuum_min_duration => $log_autovacuum_min_duration,
    }

    file { "/etc/postgresql/${_pgversion}/main/master.conf":
        ensure  => $ensure,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template('postgresql/master.conf.erb'),
        require => Class['postgresql::server'],
    }

    if $ensure == 'present' {
        exec { 'pg-initdb':
            command => "/usr/lib/postgresql/${_pgversion}/bin/initdb --locale ${locale} -D ${data_dir}",
            user    => 'postgres',
            unless  => "/usr/bin/test -f ${data_dir}/PG_VERSION",
            require => Class['postgresql::server'],
        }
    }
}