Defined Type: postgresql::server::recovery

Defined in:
manifests/server/recovery.pp

Overview

This resource manages the parameters that applies to the recovery.conf template. See README.md for more details.

Parameters:

  • restore_command (Any) (defaults to: undef)
  • archive_cleanup_command (Any) (defaults to: undef)
  • recovery_end_command (Any) (defaults to: undef)
  • recovery_target_name (Any) (defaults to: undef)
  • recovery_target_time (Any) (defaults to: undef)
  • recovery_target_xid (Any) (defaults to: undef)
  • recovery_target_inclusive (Any) (defaults to: undef)
  • recovery_target (Any) (defaults to: undef)
  • recovery_target_timeline (Any) (defaults to: undef)
  • pause_at_recovery_target (Any) (defaults to: undef)
  • standby_mode (Any) (defaults to: undef)
  • primary_conninfo (Any) (defaults to: undef)
  • primary_slot_name (Any) (defaults to: undef)
  • trigger_file (Any) (defaults to: undef)
  • recovery_min_apply_delay (Any) (defaults to: undef)
  • target (Any) (defaults to: $postgresql::server::recovery_conf_path)


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
# File 'manifests/server/recovery.pp', line 2

define postgresql::server::recovery(
  $restore_command                = undef,
  $archive_cleanup_command        = undef,
  $recovery_end_command           = undef,
  $recovery_target_name           = undef,
  $recovery_target_time           = undef,
  $recovery_target_xid            = undef,
  $recovery_target_inclusive      = undef,
  $recovery_target                = undef,
  $recovery_target_timeline       = undef,
  $pause_at_recovery_target       = undef,
  $standby_mode                   = undef,
  $primary_conninfo               = undef,
  $primary_slot_name              = undef,
  $trigger_file                   = undef,
  $recovery_min_apply_delay       = undef,
  $target                         = $postgresql::server::recovery_conf_path
) {

  if $postgresql::server::manage_recovery_conf == false {
    fail('postgresql::server::manage_recovery_conf has been disabled, so this resource is now unused and redundant, either enable that option or remove this resource from your manifests')
  } else {
    if($restore_command == undef and $archive_cleanup_command == undef and $recovery_end_command == undef
      and $recovery_target_name == undef and $recovery_target_time == undef and $recovery_target_xid == undef
      and $recovery_target_inclusive == undef and $recovery_target == undef and $recovery_target_timeline == undef
      and $pause_at_recovery_target == undef and $standby_mode == undef and $primary_conninfo == undef
      and $primary_slot_name == undef and $trigger_file == undef and $recovery_min_apply_delay == undef) {
      fail('postgresql::server::recovery use this resource but do not pass a parameter will avoid creating the recovery.conf, because it makes no sense.')
    }

    concat { $target:
      owner  => $::postgresql::server::config::user,
      group  => $::postgresql::server::config::group,
      force  => true, # do not crash if there is no recovery conf file
      mode   => '0640',
      warn   => true,
      notify => Class['postgresql::server::reload'],
    }

    # Create the recovery.conf content
    concat::fragment { 'recovery.conf':
      target  => $target,
      content => template('postgresql/recovery.conf.erb'),
    }
  }
}