Puppet Class: postgresql::config

Inherits:
postgresql
Defined in:
manifests/config.pp

Overview

Class: postgresql

postgresql::config documentation

postgres.conf concat order

00: base 80: pg_stats_statements



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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'manifests/config.pp', line 8

class postgresql::config inherits postgresql {

  Postgresql_psql {
    port => $postgresql::port,
  }

  if($postgresql::datadir==undef)
  {
    if($postgresql::params::repoprovider=='raspbian10')
    {
      $datadir_path='/var/lib/postgresql/11/main'
    }
    else
    {
      $datadir_path=$postgresql::params::datadir_default[$postgresql::version]
    }
  }
  else
  {
    $datadir_path=$postgresql::datadir
  }

  if($postgresql::pidfile==undef)
  {
    $pidfilename=$postgresql::params::pidfile[$postgresql::version]
  }
  else
  {
    $pidfilename=$postgresql::pidfile
  }

  # postgres >= 9.5
  # max_wal_size = (3 * checkpoint_segments) * 16MB

  if($postgresql::params::systemd)
  {
    if($postgresql::params::repoprovider=='raspbian10')
    {
      # Error: /usr/lib/postgresql/11/bin/pg_ctl /usr/lib/postgresql/11/bin/pg_ctl start -D /var/postgres/datadir
      # -l /var/log/postgresql/postgresql-11-main.log
      # -D /var/postgres/datadir/ -s -o
      # -c unix_socket_directories="/var/run/postgresql"
      # -c config_file="/etc/postgresql/11/main/postgresql.conf"
      # -c hba_file="/etc/postgresql/11/main/pg_hba.conf"
      # -c ident_file="/etc/postgresql/11/main/pg_ident.conf"
      # -c external_pid_file="/var/run/postgresql/11-main.pid"  exited with status 1:

      # file { '/etc/postgresql/11/main/pg_hba.conf':
      #   ensure => 'link',
      #   target => "${datadir_path}/pg_hba.conf",
      # }
      # TO AVOID CRICULAR DEPENDENCY:
      exec { 'ln hba raspberry':
        command => "ln -f -s ${datadir_path}/pg_hba.conf /etc/postgresql/11/main/pg_hba.conf",
        unless  => "ls -l /etc/postgresql/11/main/pg_hba.conf | grep ${datadir_path}/pg_hba.conf",
        path    => '/usr/sbin:/usr/bin:/sbin:/bin',
      }

      file { '/etc/postgresql/11/main/postgresql.conf':
        ensure => 'link',
        target => "${datadir_path}/postgresql.conf",
      }
    }
    else
    {
      systemd::service::dropin { $postgresql::params::servicename[$postgresql::version]:
        env_vars => [ "PGDATA=${datadir_path}" ],
        before   => Class['postgresql::service'],
      }
    }
  }

  if($postgresql::manage_configfile)
  {
    concat { "${datadir_path}/postgresql.conf":
      ensure => 'present',
      owner  => $postgresql::params::postgresuser,
      group  => $postgresql::params::postgresgroup,
      mode   => '0600',
    }

    concat::fragment{ "base postgresql ${datadir_path}":
      target  => "${datadir_path}/postgresql.conf",
      content => template("${module_name}/postgresconf.erb"),
      order   => '00',
    }
  }

  if($postgresql::params::sysconfig)
  {
    file { "/etc/sysconfig/pgsql/${postgresql::params::servicename[$postgresql::version]}":
      ensure  => 'present',
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => "PGPORT=${postgresql::port}\n",
    }
  }

  file { '/etc/profile.d/psql.sh':
    ensure  => 'present',
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => "alias psql='psql -p ${postgresql::port}'\n",
  }

}