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
58
59
60
61
62
63
|
# File 'manifests/recoveryconf.pp', line 4
class postgresql::recoveryconf(
$masterhost = undef,
$masterusername = undef,
$masterpassword = undef,
$masterport = $postgresql::params::port_default,
$datadir = $postgresql::datadir,
$restore_command = undef,
$archive_cleanup_command = undef,
$recovery_min_apply_delay = undef,
$primary_slot_name = undef,
$init_with_pg_basebackup = true,
$standby_mode = true,
$trigger_file = '/tmp/postgresql.enable_master_mode',
) inherits postgresql::params {
Exec {
path => '/usr/sbin:/usr/bin:/sbin:/bin',
}
if($datadir==undef)
{
$datadir_path=$postgresql::params::datadir_default[$postgresql::version]
}
else
{
$datadir_path = $datadir
}
if($masterhost!=undef and $init_with_pg_basebackup and $standby_mode)
{
file { "${postgresql::params::postgreshome}/.pgpass":
ensure => 'present',
owner => $postgresql::params::postgresuser,
group => $postgresql::params::postgresuser,
mode => '0600',
content => "${masterhost}:${masterport}:*:${masterusername}:${masterpassword}\n",
require => Class['::postgresql::install'],
}
exec { 'init streaming replication':
command => "bash -xc 'pg_basebackup -D ${datadir_path} -h ${masterhost} -p ${masterport} -U ${masterusername} -w -v -X stream > $(dirname ${datadir_path})/.streaming_replication_init.log 2>&1'",
user => $postgresql::params::postgresuser,
creates => "${datadir_path}/recovery.conf",
require => File["${postgresql::params::postgreshome}/.pgpass"],
before => Class['::postgresql::config'],
timeout => 0,
}
-> Exec <| tag == 'post-recoveryconf' |>
-> File <| tag == 'post-recoveryconf' |>
}
file { "${datadir_path}/recovery.conf":
ensure => 'present',
owner => $postgresql::params::postgresuser,
group => $postgresql::params::postgresgroup,
mode => '0600',
content => template("${module_name}/recoveryconf.erb"),
require => Exec['init streaming replication'],
before => Class['::postgresql::config'],
}
}
|