Defined Type: postgresql::server::recovery

Defined in:
manifests/server/recovery.pp

Summary

This resource manages the parameters that applies to the recovery.conf template.

Overview

Note:

Allows you to create the content for recovery.conf. For more details see the usage example and the PostgreSQL documentation. Every parameter value is a string set in the template except recovery_target_inclusive, pause_at_recovery_target, standby_mode and recovery_min_apply_delay. A detailed description of all listed parameters can be found in the PostgreSQL documentation. Only the specified parameters are recognized in the template. The recovery.conf is only created if at least one parameter is set and manage_recovery_conf is set to true.

Parameters:

  • restore_command (Any) (defaults to: undef)

    The shell command to execute to retrieve an archived segment of the WAL file series.

  • archive_cleanup_command (Any) (defaults to: undef)

    This optional parameter specifies a shell command that will be executed at every restartpoint.

  • recovery_end_command (Any) (defaults to: undef)

    This parameter specifies a shell command that will be executed once only at the end of recovery.

  • recovery_target_name (Any) (defaults to: undef)

    This parameter specifies the named restore point (created with pg_create_restore_point()) to which recovery will proceed.

  • recovery_target_time (Any) (defaults to: undef)

    This parameter specifies the time stamp up to which recovery will proceed.

  • recovery_target_xid (Any) (defaults to: undef)

    This parameter specifies the transaction ID up to which recovery will proceed.

  • recovery_target_inclusive (Any) (defaults to: undef)

    Specifies whether to stop just after the specified recovery target (true), or just before the recovery target (false).

  • recovery_target (Any) (defaults to: undef)

    This parameter specifies that recovery should end as soon as a consistent state is reached, i.e. as early as possible.

  • recovery_target_timeline (Any) (defaults to: undef)

    Specifies recovering into a particular timeline.

  • pause_at_recovery_target (Any) (defaults to: undef)

    Specifies whether recovery should pause when the recovery target is reached.

  • standby_mode (Any) (defaults to: undef)

    Specifies whether to start the PostgreSQL server as a standby.

  • primary_conninfo (Any) (defaults to: undef)

    Specifies a connection string to be used for the standby server to connect with the primary.

  • primary_slot_name (Any) (defaults to: undef)

    Optionally specifies an existing replication slot to be used when connecting to the primary via streaming replication to control resource removal on the upstream node.

  • trigger_file (Any) (defaults to: undef)

    Specifies a trigger file whose presence ends recovery in the standby.

  • recovery_min_apply_delay (Any) (defaults to: undef)

    This parameter allows you to delay recovery by a fixed period of time, measured in milliseconds if no unit is specified.

  • target (Any) (defaults to: $postgresql::server::recovery_conf_path)

    Provides the target for the rule, and is generally an internal only property. Use with caution.



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/server/recovery.pp', line 25

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