Puppet Class: postgresql::globals

Inherited by:
postgresql::params
Defined in:
manifests/globals.pp

Summary

Class for setting cross-class global overrides.

Overview

Note:

Most server-specific defaults should be overridden in the postgresql::server class. This class should be used only if you are using a non-standard OS, or if you are changing elements that can only be changed here, such as version or manage_package_repo.

Parameters:

  • client_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL client package name.

  • server_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL server package name.

  • contrib_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL contrib package name.

  • devel_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL devel package name.

  • java_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL java package name.

  • docs_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL docs package name.

  • perl_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL Perl package name.

  • plperl_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL PL/Perl package name.

  • plpython_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL PL/Python package name.

  • python_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL Python package name.

  • postgis_package_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL PostGIS package name.

  • service_name (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL service name.

  • service_provider (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL service provider.

  • service_status (Optional[String[1]]) (defaults to: undef)

    Overrides the default status check command for your PostgreSQL service.

  • default_database (Optional[String[1]]) (defaults to: undef)

    Specifies the name of the default database to connect with.

  • validcon_script_path (Optional[String[1]]) (defaults to: undef)

    Scipt path for the connection validation check.

  • initdb_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to the initdb command.

  • psql_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Sets the path to the psql command.

  • pg_hba_conf_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Specifies the path to your pg_hba.conf file.

  • pg_ident_conf_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Specifies the path to your pg_ident.conf file.

  • postgresql_conf_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Sets the path to your postgresql.conf file.

  • postgresql_conf_mode (Optional[Stdlib::Filemode]) (defaults to: undef)

    Sets the mode of your postgresql.conf file. Only relevant if manage_postgresql_conf_perms is true.

  • recovery_conf_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Path to your recovery.conf file.

  • default_connect_settings (Hash) (defaults to: {})

    Default connection settings.

  • pg_hba_conf_defaults (Optional[Boolean]) (defaults to: undef)

    Disables the defaults supplied with the module for pg_hba.conf if set to false.

  • datadir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Overrides the default PostgreSQL data directory for the target platform. Changing the datadir after installation causes the server to come to a full stop before making the change. For Red Hat systems, the data directory must be labeled appropriately for SELinux. On Ubuntu, you must explicitly set needs_initdb = true to allow Puppet to initialize the database in the new datadir (needs_initdb defaults to true on other systems). Warning! If datadir is changed from the default, Puppet does not manage purging of the original data directory, which causes it to fail if the data directory is changed back to the original

  • confdir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Overrides the default PostgreSQL configuration directory for the target platform.

  • bindir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Overrides the default PostgreSQL binaries directory for the target platform.

  • xlogdir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Overrides the default PostgreSQL xlog directory.

  • logdir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Overrides the default PostgreSQL log directory.

  • log_line_prefix (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL log prefix.

  • user (Optional[String[1]]) (defaults to: undef)

    Overrides the default PostgreSQL super user and owner of PostgreSQL related files in the file system.

  • group (Optional[String[1]]) (defaults to: undef)

    Overrides the default postgres user group to be used for related files in the file system.

  • version (Optional[String[1]]) (defaults to: undef)

    The version of PostgreSQL to install and manage.

  • postgis_version (Optional[String[1]]) (defaults to: undef)

    Defines the version of PostGIS to install, if you install PostGIS.

  • repo_proxy (Optional[String[1]]) (defaults to: undef)

    Sets the proxy option for the official PostgreSQL yum-repositories only.

  • repo_baseurl (Optional[String[1]]) (defaults to: undef)

    Sets the baseurl for the PostgreSQL repository. Useful if you host your own mirror of the repository.

  • yum_repo_commonurl (Optional[String[1]]) (defaults to: undef)

    Sets the url for the PostgreSQL common Yum repository. Useful if you host your own mirror of the YUM repository.

  • apt_source_release (Optional[String[1]]) (defaults to: undef)

    Overrides the default release for the apt source.

  • needs_initdb (Optional[Boolean]) (defaults to: undef)

    Explicitly calls the initdb operation after the server package is installed and before the PostgreSQL service is started.

  • encoding (Optional[String[1]]) (defaults to: undef)

    Sets the default encoding for all databases created with this module. On certain operating systems, this is also used during the template1 initialization, so it becomes a default outside of the module as well.

  • locale (Optional[String[1]]) (defaults to: undef)

    Sets the default database locale for all databases created with this module. On certain operating systems, this is also used during the template1 initialization, so it becomes a default outside of the module as well. On Debian, you’ll need to ensure that the ‘locales-all’ package is installed for full functionality of PostgreSQL.

  • data_checksums (Optional[Boolean]) (defaults to: undef)

    Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. Warning: This option is used during initialization by initdb, and cannot be changed later.

  • timezone (Optional[String[1]]) (defaults to: undef)

    Sets the default timezone of the postgresql server. The postgresql built-in default is taking the systems timezone information.

  • manage_pg_hba_conf (Optional[Boolean]) (defaults to: undef)

    Allow Puppet to manage the pg_hba.conf file.

  • manage_pg_ident_conf (Optional[Boolean]) (defaults to: undef)

    Allow Puppet to manage the pg_ident.conf file.

  • manage_recovery_conf (Optional[Boolean]) (defaults to: undef)

    Allow Puppet to manage the recovery.conf file.

  • manage_postgresql_conf_perms (Optional[Boolean]) (defaults to: undef)

    Whether to manage the postgresql conf file permissions. This means owner, group and mode. Contents are not managed but should be managed through postgresql::server::config_entry.

  • manage_selinux (Optional[Boolean]) (defaults to: undef)

    Allows Puppet to manage the appropriate configuration file for selinux.

  • manage_datadir (Optional[Boolean]) (defaults to: undef)

    Set to false if you have file{ $datadir: } already defined

  • manage_logdir (Optional[Boolean]) (defaults to: undef)

    Set to false if you have file{ $logdir: } already defined

  • manage_xlogdir (Optional[Boolean]) (defaults to: undef)

    Set to false if you have file{ $xlogdir: } already defined

  • manage_package_repo (Optional[Boolean]) (defaults to: undef)

    Sets up official PostgreSQL repositories on your host if set to true.

  • manage_dnf_module (Boolean) (defaults to: false)

    Manage the DNF module. This only makes sense on distributions that use DNF package manager, such as EL8, EL9 or Fedora.

  • module_workdir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Specifies working directory under which the psql command should be executed. May need to specify if ‘/tmp’ is on volume mounted with noexec option.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'manifests/globals.pp', line 105

class postgresql::globals (
  Optional[String[1]] $client_package_name         = undef,
  Optional[String[1]] $server_package_name         = undef,
  Optional[String[1]] $contrib_package_name        = undef,
  Optional[String[1]] $devel_package_name          = undef,
  Optional[String[1]] $java_package_name           = undef,
  Optional[String[1]] $docs_package_name           = undef,
  Optional[String[1]] $perl_package_name           = undef,
  Optional[String[1]] $plperl_package_name         = undef,
  Optional[String[1]] $plpython_package_name       = undef,
  Optional[String[1]] $python_package_name         = undef,
  Optional[String[1]] $postgis_package_name        = undef,

  Optional[String[1]] $service_name                = undef,
  Optional[String[1]] $service_provider            = undef,
  Optional[String[1]] $service_status              = undef,
  Optional[String[1]] $default_database            = undef,

  Optional[String[1]] $validcon_script_path        = undef,

  Optional[Stdlib::Absolutepath] $initdb_path          = undef,
  Optional[Stdlib::Absolutepath] $psql_path            = undef,
  Optional[Stdlib::Absolutepath] $pg_hba_conf_path     = undef,
  Optional[Stdlib::Absolutepath] $pg_ident_conf_path   = undef,
  Optional[Stdlib::Absolutepath] $postgresql_conf_path = undef,
  Optional[Stdlib::Filemode] $postgresql_conf_mode     = undef,
  Optional[Stdlib::Absolutepath] $recovery_conf_path   = undef,
  Hash $default_connect_settings                       = {},

  Optional[Boolean] $pg_hba_conf_defaults          = undef,

  Optional[Stdlib::Absolutepath] $datadir          = undef,
  Optional[Stdlib::Absolutepath] $confdir          = undef,
  Optional[Stdlib::Absolutepath] $bindir           = undef,
  Optional[Stdlib::Absolutepath] $xlogdir          = undef,
  Optional[Stdlib::Absolutepath] $logdir           = undef,
  Optional[String[1]] $log_line_prefix             = undef,
  Optional[Boolean] $manage_datadir                = undef,
  Optional[Boolean] $manage_logdir                 = undef,
  Optional[Boolean] $manage_xlogdir                = undef,

  Optional[String[1]] $user                        = undef,
  Optional[String[1]] $group                       = undef,

  Optional[String[1]] $version                     = undef,
  Optional[String[1]] $postgis_version             = undef,
  Optional[String[1]] $repo_proxy                  = undef,
  Optional[String[1]] $repo_baseurl                = undef,
  Optional[String[1]] $yum_repo_commonurl          = undef,
  Optional[String[1]] $apt_source_release          = undef,

  Optional[Boolean] $needs_initdb                  = undef,

  Optional[String[1]] $encoding                    = undef,
  Optional[String[1]] $locale                      = undef,
  Optional[Boolean] $data_checksums                = undef,
  Optional[String[1]] $timezone                    = undef,

  Optional[Boolean] $manage_pg_hba_conf            = undef,
  Optional[Boolean] $manage_pg_ident_conf          = undef,
  Optional[Boolean] $manage_recovery_conf          = undef,
  Optional[Boolean] $manage_postgresql_conf_perms  = undef,
  Optional[Boolean] $manage_selinux                = undef,

  Optional[Boolean] $manage_package_repo           = undef,
  Boolean $manage_dnf_module                       = false,
  Optional[Stdlib::Absolutepath] $module_workdir   = undef,
) {
  # We are determining this here, because it is needed by the package repo
  # class.
  $default_version = $facts['os']['family'] ? {
    /^(RedHat|Linux)/ => $facts['os']['name'] ? {
      'Fedora' => $facts['os']['release']['major'] ? {
        /^(38)$/       => '15',
        /^(36|37)$/    => '14',
        /^(34|35)$/    => '13',
        /^(32|33)$/    => '12',
        /^(31)$/       => '11.6',
        /^(30)$/       => '11.2',
        /^(29)$/       => '10.6',
        /^(28)$/       => '10.4',
        /^(26|27)$/    => '9.6',
        /^(24|25)$/    => '9.5',
        /^(22|23)$/    => '9.4',
        /^(21)$/       => '9.3',
        /^(18|19|20)$/ => '9.2',
        /^(17)$/       => '9.1',
        default        => undef,
      },
      'Amazon' => '9.2',
      default => $facts['os']['release']['major'] ? {
        '9'     => '13',
        '8'     => '10',
        '7'     => '9.2',
        default => undef,
      },
    },
    'Debian' => $facts['os']['name'] ? {
      'Debian' => $facts['os']['release']['major'] ? {
        '10'    => '11',
        '11'    => '13',
        '12'    => '15',
        default => undef,
      },
      'Ubuntu' => $facts['os']['release']['major'] ? {
        /^(18.04)$/ => '10',
        /^(20.04)$/ => '12',
        /^(21.04|21.10)$/ => '13',
        /^(22.04)$/ => '14',
        default => undef,
      },
      default => undef,
    },
    'Archlinux' => '9.2',
    'Gentoo' => '9.5',
    'FreeBSD' => '12',
    'OpenBSD' => $facts['os']['release']['full'] ? {
      /5\.6/ => '9.3',
      /5\.[7-9]/ => '9.4',
      /6\.[0-9]/ => '9.5',
    },
    'Suse' => $facts['os']['name'] ? {
      'SLES' => $facts['os']['release']['full'] ? {
        /11\.[0-3]/ => '91',
        /11\.4/     => '94',
        /12\.0/     => '93',
        /12\.[1-3]/ => '94',
        /12\.[4-5]/ => '12',
        /15\.[0-9]/ => '14',
        default     => '96',
      },
      'OpenSuSE' => $facts['os']['release']['full'] ? {
        /42\.[1-2]/ => '94',
        default     => '96',
      },
      default => undef,
    },
    default => undef,
  }
  $globals_version = pick($version, $default_version, 'unknown')
  if($globals_version == 'unknown') {
    fail('No preferred version defined or automatically detected.')
  }

  $default_postgis_version = $globals_version ? {
    '9.0'   => '2.1',
    '9.1'   => '2.1',
    '91'    => '2.1',
    '9.2'   => '2.3',
    '9.3'   => '2.3',
    '93'    => '2.3',
    '9.4'   => '2.3',
    '9.5'   => '2.3',
    '9.6'   => '2.3',
    '10'    => '2.4',
    '11'    => '3.0',
    '12'    => '3.0',
    default => undef,
  }
  $globals_postgis_version = $postgis_version ? {
    undef   => $default_postgis_version,
    default => $postgis_version,
  }

  # Setup of the repo only makes sense globally, so we are doing this here.
  if($manage_package_repo) {
    class { 'postgresql::repo':
      version   => $globals_version,
      proxy     => $repo_proxy,
      baseurl   => $repo_baseurl,
      commonurl => $yum_repo_commonurl,
      release   => $apt_source_release,
    }
  }

  if $manage_dnf_module {
    class { 'postgresql::dnfmodule':
      ensure => $globals_version,
    }
  }
}