Puppet Class: postgresql::master

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

Overview

Parameters:

  • master_server (Stdlib::Host) (defaults to: $::fqdn)
  • includes (Array) (defaults to: [])
  • pgversion (String) (defaults to: $::lsbdistcodename)
  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • 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)
  • ssldir (Optional[Stdlib::Unixpath]) (defaults to: undef)
  • locale (String) (defaults to: 'en_US.UTF-8')
  • sync_replicas (Optional[Array[String]]) (defaults to: undef)
  • sync_count (Integer) (defaults to: 1)
  • sync_mode (String) (defaults to: 'on')


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
# File 'modules/postgresql/manifests/master.pp', line 37

class postgresql::master(
    Stdlib::Host $master_server=$::fqdn,
    Array $includes=[],
    String $pgversion = $::lsbdistcodename ? {
        'buster'  => '11',
        'stretch' => '9.6',
    },
    Wmflib::Ensure $ensure='present',
    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,
    Optional[Stdlib::Unixpath] $ssldir=undef,
    String $locale='en_US.UTF-8',
    Optional[Array[String]] $sync_replicas=undef,
    Integer $sync_count=1,
    String $sync_mode='on',
) {

    $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,
    }

    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'],
        }
    }
}