Puppet Class: postgresql::dirs

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

Overview

Class: postgresql::dirs

This class creates postgresql directories. It's split off from the rest of the classes in order to allow requiring it without causing dependency loops. You should not be using it directly

Parameters:

pgversion
    Defaults to 9.6 in Debian Stretch and 11 in Buster
    FIXME: Just use the unversioned package name and let apt
    do the right thing.
ensure
    Defaults to present
root_dir
    The root directory for postgresql data. The actual directory will be
    "${root_dir}/${pgversion}/main".

Actions:

Create postgres directories

Requires:

Sample Usage:

include postgresql::dirs

Parameters:

  • ensure (String) (defaults to: 'present')
  • root_dir (Stdlib::Unixpath) (defaults to: '/var/lib/postgresql')
  • pgversion (Optional[Numeric]) (defaults to: undef)


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

class postgresql::dirs(
    String            $ensure    = 'present',
    Stdlib::Unixpath  $root_dir  = '/var/lib/postgresql',
    Optional[Numeric] $pgversion = undef,
) {
    $_pgversion = $pgversion ? {
        undef   => $facts['os']['distro']['codename'] ? {
            'bullseye' => 13,
            'bookworm' => 15,
            default   => 11,
        },
        default => $pgversion,
    }
    $data_dir = "${root_dir}/${_pgversion}/main"
    $config_dir = "/etc/postgresql/${_pgversion}"

    # Also creates the 'postgres' user
    ensure_packages('postgresql-common')

    file {  [ $root_dir, "${root_dir}/${_pgversion}" ] :
        ensure  => stdlib::ensure($ensure, 'directory'),
        owner   => 'postgres',
        group   => 'postgres',
        mode    => '0755',
        require => Package['postgresql-common'],
    }

    file { $data_dir:
        ensure  => stdlib::ensure($ensure, 'directory'),
        owner   => 'postgres',
        group   => 'postgres',
        mode    => '0700',
        require => Package['postgresql-common'],
    }

    file {  [ $config_dir, "${config_dir}/main" ] :
        ensure  => stdlib::ensure($ensure, 'directory'),
        owner   => 'postgres',
        group   => 'postgres',
        mode    => '0755',
        require => Package['postgresql-common'],
    }
}