Defined Type: postgresql::cluster

Defined in:
manifests/cluster.pp

Overview

Parameters:

  • cluster_name (Any) (defaults to: $name)
  • version (Any) (defaults to: '8.4')
  • owner (Any) (defaults to: '')
  • group (Any) (defaults to: '')
  • locale (Any) (defaults to: '')
  • absent (Any) (defaults to: false)


1
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
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'manifests/cluster.pp', line 1

define postgresql::cluster(
  $cluster_name = $name,
  $version      = '8.4',
  $owner        = '',
  $group        = '',
  $locale       = '',
  $absent       = false
) {

  include postgresql

  $bool_absent=any2bool($absent)

  $create_cmd = "pg_createcluster ${version} ${cluster_name}"

  $o_owner = $owner ? {
    ''      => "-u ${::postgresql::config_file_owner}",
    default => "-u ${owner}",
  }

  $o_group = $group ? {
    ''      => "-g ${::postgresql::config_file_group}",
    default => "-g ${group}",
  }

  $o_locale = $locale ? {
    ''      => '',
    default => "--locale=${locale}",
  }
  $options = "${o_owner} ${o_group} ${o_locale}"
  $full_create_cmd = "${create_cmd} ${options}"

  $drop_cmd = "pg_dropcluster --stop ${version} ${cluster_name}"

  $ls_cmd = "pg_lsclusters -h|awk '{ print \$2 }'|grep ${cluster_name}"

  $manage_cmd = $bool_absent ? {
    true  => $drop_cmd,
    false => $full_create_cmd,
  }

  $manage_onlyif = $bool_absent ? {
    true  => $ls_cmd,
    false => undef,
  }

  $manage_unless = $bool_absent ? {
    false => $ls_cmd,
    true  => undef,
  }

  exec { "postgres-manage-cluster-${name}":
    command => $manage_cmd,
    path    => '/bin:/usr/bin:/sbin:/usr/sbin',
    onlyif  => $manage_onlyif,
    unless  => $manage_unless,
    require => Package['postgresql'],
    notify  => $postgresql::manage_service_autorestart,
  }
}