Puppet Class: postgresql::server

Inherits:
postgresql::params
Defined in:
manifests/server.pp

Summary

This installs a PostgreSQL server

Overview

Parameters:

  • postgres_password (Optional[Variant[String[1], Sensitive[String[1]], Integer]]) (defaults to: undef)

    Sets the password for the postgres user to your specified value. By default, this setting uses the superuser account in the Postgres database, with a user called postgres and no password.

  • package_name (String[1]) (defaults to: $postgresql::params::server_package_name)

    Specifies the name of the package to use for installing the server software.

  • package_ensure (Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]]) (defaults to: $postgresql::params::package_ensure)

    Passes a value through to the package resource when creating the server instance.

  • plperl_package_name (Optional[String[1]]) (defaults to: $postgresql::params::plperl_package_name)

    Sets the default package name for the PL/Perl extension.

  • plpython_package_name (Optional[String[1]]) (defaults to: $postgresql::params::plpython_package_name)

    Sets the default package name for the PL/Python extension.

  • service_ensure (Variant[Enum['running', 'stopped'], Boolean]) (defaults to: $postgresql::params::service_ensure)

    Ensure service is installed

  • service_enable (Boolean) (defaults to: $postgresql::params::service_enable)

    Enable the PostgreSQL service

  • service_manage (Boolean) (defaults to: $postgresql::params::service_manage)

    Defines whether or not Puppet should manage the service.

  • service_name (String[1]) (defaults to: $postgresql::params::service_name)

    Overrides the default PostgreSQL service name.

  • service_restart_on_change (Boolean) (defaults to: $postgresql::params::service_restart_on_change)

    Overrides the default behavior to restart your PostgreSQL service when a config entry has been changed that requires a service restart to become active.

  • service_provider (Optional[String[1]]) (defaults to: $postgresql::params::service_provider)

    Overrides the default PostgreSQL service provider.

  • service_reload (String[1]) (defaults to: $postgresql::params::service_reload)

    Overrides the default reload command for your PostgreSQL service.

  • service_status (Optional[String[1]]) (defaults to: $postgresql::params::service_status)

    Overrides the default status check command for your PostgreSQL service.

  • default_database (String[1]) (defaults to: $postgresql::params::default_database)

    Specifies the name of the default database to connect with. On most systems this is ‘postgres’.

  • default_connect_settings (Hash) (defaults to: $postgresql::globals::default_connect_settings)

    Specifies a hash of environment variables used when connecting to a remote server. Becomes the default for other defined types, such as postgresql::server::role.

  • listen_addresses (Optional[Variant[String[1], Array[String[1]]]]) (defaults to: $postgresql::params::listen_addresses)

    Address list on which the PostgreSQL service will listen

  • port (Stdlib::Port) (defaults to: $postgresql::params::port)

    Specifies the port for the PostgreSQL server to listen on. Note: The same port number is used for all IP addresses the server listens on. Also, for Red Hat systems and early Debian systems, changing the port causes the server to come to a full stop before being able to make the change. Default value: 5432. Meaning the Postgres server listens on TCP port 5432.

  • ip_mask_deny_postgres_user (String[1]) (defaults to: $postgresql::params::ip_mask_deny_postgres_user)

    Specifies the IP mask from which remote connections should be denied for the postgres superuser. Default value: ‘0.0.0.0/0’, which denies any remote connection.

  • ip_mask_allow_all_users (String[1]) (defaults to: $postgresql::params::ip_mask_allow_all_users)

    Overrides PostgreSQL defaults for remote connections. By default, PostgreSQL does not allow database user accounts to connect via TCP from remote machines. If you’d like to allow this, you can override this setting. Set to ‘0.0.0.0/0’ to allow database users to connect from any remote machine, or ‘192.168.0.0/1’ to allow connections from any machine on your local ‘192.168’ subnet. Default value: ‘127.0.0.1/32’.

  • ipv4acls (Array[String[1]]) (defaults to: $postgresql::params::ipv4acls)

    Lists strings for access control for connection method, users, databases, IPv4 addresses;

  • ipv6acls (Array[String[1]]) (defaults to: $postgresql::params::ipv6acls)

    Lists strings for access control for connection method, users, databases, IPv6 addresses.

  • initdb_path (Stdlib::Absolutepath) (defaults to: $postgresql::params::initdb_path)

    Specifies the path to the initdb command.

  • psql_path (Stdlib::Absolutepath) (defaults to: $postgresql::params::psql_path)

    Specifies the path to the psql command.

  • pg_hba_conf_path (Stdlib::Absolutepath) (defaults to: $postgresql::params::pg_hba_conf_path)

    Specifies the path to your pg_hba.conf file.

  • pg_ident_conf_path (Stdlib::Absolutepath) (defaults to: $postgresql::params::pg_ident_conf_path)

    Specifies the path to your pg_ident.conf file.

  • postgresql_conf_path (Stdlib::Absolutepath) (defaults to: $postgresql::params::postgresql_conf_path)

    Specifies the path to your postgresql.conf file.

  • postgresql_conf_mode (Optional[Stdlib::Filemode]) (defaults to: $postgresql::params::postgresql_conf_mode)

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

  • recovery_conf_path (Stdlib::Absolutepath) (defaults to: $postgresql::params::recovery_conf_path)

    Specifies the path to your recovery.conf file.

  • datadir (Stdlib::Absolutepath) (defaults to: $postgresql::params::datadir)

    PostgreSQL data directory

  • xlogdir (Optional[Stdlib::Absolutepath]) (defaults to: $postgresql::params::xlogdir)

    PostgreSQL xlog directory

  • logdir (Optional[Stdlib::Absolutepath]) (defaults to: $postgresql::params::logdir)

    PostgreSQL log directory

  • log_line_prefix (Optional[String[1]]) (defaults to: $postgresql::params::log_line_prefix)

    PostgreSQL log line prefix

  • pg_hba_conf_defaults (Boolean) (defaults to: $postgresql::params::pg_hba_conf_defaults)

    If false, disables the defaults supplied with the module for pg_hba.conf. This is useful if you disagree with the defaults and wish to override them yourself. Be sure that your changes of course align with the rest of the module, as some access is required to perform basic psql operations for example.

  • user (String[1]) (defaults to: $postgresql::params::user)

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

  • group (String[1]) (defaults to: $postgresql::params::group)

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

  • needs_initdb (Boolean) (defaults to: $postgresql::params::needs_initdb)

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

  • encoding (Optional[String[1]]) (defaults to: $postgresql::params::encoding)

    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: $postgresql::params::locale)

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

  • data_checksums (Optional[Boolean]) (defaults to: $postgresql::params::data_checksums)

    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. If set, checksums are calculated for all objects, in all databases.

  • timezone (Optional[String[1]]) (defaults to: $postgresql::params::timezone)

    Set timezone for the PostgreSQL instance

  • manage_pg_hba_conf (Boolean) (defaults to: $postgresql::params::manage_pg_hba_conf)

    Boolean. Whether to manage the pg_hba.conf.

  • manage_pg_ident_conf (Boolean) (defaults to: $postgresql::params::manage_pg_ident_conf)

    Boolean. Overwrites the pg_ident.conf file.

  • manage_recovery_conf (Boolean) (defaults to: $postgresql::params::manage_recovery_conf)

    Boolean. Specifies whether or not manage the recovery.conf.

  • manage_postgresql_conf_perms (Boolean) (defaults to: $postgresql::params::manage_postgresql_conf_perms)

    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 (Boolean) (defaults to: $postgresql::params::manage_selinux)

    Specifies whether or not manage the conf file for selinux.

  • module_workdir (Stdlib::Absolutepath) (defaults to: $postgresql::params::module_workdir)

    Working directory for the PostgreSQL module

  • manage_datadir (Boolean) (defaults to: $postgresql::params::manage_datadir)

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

  • manage_logdir (Boolean) (defaults to: $postgresql::params::manage_logdir)

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

  • manage_xlogdir (Boolean) (defaults to: $postgresql::params::manage_xlogdir)

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

  • password_encryption (Postgresql::Pg_password_encryption) (defaults to: $postgresql::params::password_encryption)

    Specify the type of encryption set for the password.

  • pg_hba_auth_password_encryption (Optional[Postgresql::Pg_password_encryption]) (defaults to: undef)

    Specify the type of encryption set for the password in pg_hba_conf, this value is usefull if you want to start enforcing scram-sha-256, but give users transition time.

  • roles (Hash[String, Hash]) (defaults to: {})

    Specifies a hash from which to generate postgresql::server::role resources.

  • config_entries (Hash[String, Any]) (defaults to: {})

    Specifies a hash from which to generate postgresql::server::config_entry resources.

  • pg_hba_rules (Postgresql::Pg_hba_rules) (defaults to: {})

    Specifies a hash from which to generate postgresql::server::pg_hba_rule resources.

  • backup_enable (Boolean) (defaults to: $postgresql::params::backup_enable)

    Whether a backup job should be enabled.

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

    A hash of options that should be passed through to the backup provider.

  • backup_provider (Enum['pg_dump']) (defaults to: $postgresql::params::backup_provider)

    Specifies the backup provider to use.

  • extra_systemd_config (Optional[String]) (defaults to: $postgresql::params::extra_systemd_config)

    Adds extra config to systemd config file, can for instance be used to add extra openfiles. This can be a multi line string

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

    auth method used by default for host authorization

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

    auth method used by default for local authorization

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

    locale used for logging and system messages

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

    username of user running the postgres instance



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
# File 'manifests/server.pp', line 117

class postgresql::server (
  Optional[Variant[String[1], Sensitive[String[1]], Integer]] $postgres_password = undef,

  Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $package_ensure = $postgresql::params::package_ensure, # lint:ignore:140chars
  String[1]                                          $package_name                 = $postgresql::params::server_package_name,

  Optional[String[1]]                                $plperl_package_name          = $postgresql::params::plperl_package_name,
  Optional[String[1]]                                $plpython_package_name        = $postgresql::params::plpython_package_name,

  Variant[Enum['running', 'stopped'], Boolean]       $service_ensure               = $postgresql::params::service_ensure,
  Boolean                                            $service_enable               = $postgresql::params::service_enable,
  Boolean                                            $service_manage               = $postgresql::params::service_manage,
  String[1]                                          $service_name                 = $postgresql::params::service_name,
  Boolean                                            $service_restart_on_change    = $postgresql::params::service_restart_on_change,
  Optional[String[1]]                                $service_provider             = $postgresql::params::service_provider,
  String[1]                                          $service_reload               = $postgresql::params::service_reload,
  Optional[String[1]]                                $service_status               = $postgresql::params::service_status,
  String[1]                                          $default_database             = $postgresql::params::default_database,
  Hash                                               $default_connect_settings     = $postgresql::globals::default_connect_settings,
  Optional[Variant[String[1], Array[String[1]]]]     $listen_addresses             = $postgresql::params::listen_addresses,
  Stdlib::Port                                       $port                         = $postgresql::params::port,
  String[1]                                          $ip_mask_deny_postgres_user   = $postgresql::params::ip_mask_deny_postgres_user,
  String[1]                                          $ip_mask_allow_all_users      = $postgresql::params::ip_mask_allow_all_users,
  Array[String[1]]                                   $ipv4acls                     = $postgresql::params::ipv4acls,
  Array[String[1]]                                   $ipv6acls                     = $postgresql::params::ipv6acls,

  Stdlib::Absolutepath                               $initdb_path                  = $postgresql::params::initdb_path,
  Stdlib::Absolutepath                               $psql_path                    = $postgresql::params::psql_path,
  Stdlib::Absolutepath                               $pg_hba_conf_path             = $postgresql::params::pg_hba_conf_path,
  Stdlib::Absolutepath                               $pg_ident_conf_path           = $postgresql::params::pg_ident_conf_path,
  Stdlib::Absolutepath                               $postgresql_conf_path         = $postgresql::params::postgresql_conf_path,
  Optional[Stdlib::Filemode]                         $postgresql_conf_mode         = $postgresql::params::postgresql_conf_mode,
  Stdlib::Absolutepath                               $recovery_conf_path           = $postgresql::params::recovery_conf_path,

  Stdlib::Absolutepath                               $datadir                      = $postgresql::params::datadir,
  Optional[Stdlib::Absolutepath]                     $xlogdir                      = $postgresql::params::xlogdir,
  Optional[Stdlib::Absolutepath]                     $logdir                       = $postgresql::params::logdir,

  Optional[String[1]]                                $log_line_prefix              = $postgresql::params::log_line_prefix,

  Boolean                                            $pg_hba_conf_defaults         = $postgresql::params::pg_hba_conf_defaults,

  String[1]                                          $user                         = $postgresql::params::user,
  String[1]                                          $group                        = $postgresql::params::group,

  Boolean                                            $needs_initdb                 = $postgresql::params::needs_initdb,

  Optional[String[1]]                                $auth_host                    = undef,
  Optional[String[1]]                                $auth_local                   = undef,
  Optional[String[1]]                                $encoding                     = $postgresql::params::encoding,
  Optional[String[1]]                                $locale                       = $postgresql::params::locale,
  Optional[String[1]]                                $lc_messages                  = undef,
  Optional[Boolean]                                  $data_checksums               = $postgresql::params::data_checksums,
  Optional[String[1]]                                $username                     = $user,
  Optional[String[1]]                                $timezone                     = $postgresql::params::timezone,

  Boolean                                            $manage_pg_hba_conf           = $postgresql::params::manage_pg_hba_conf,
  Boolean                                            $manage_pg_ident_conf         = $postgresql::params::manage_pg_ident_conf,
  Boolean                                            $manage_recovery_conf         = $postgresql::params::manage_recovery_conf,
  Boolean                                            $manage_postgresql_conf_perms = $postgresql::params::manage_postgresql_conf_perms,
  Boolean                                            $manage_selinux               = $postgresql::params::manage_selinux,
  Stdlib::Absolutepath                               $module_workdir               = $postgresql::params::module_workdir,

  Boolean                                            $manage_datadir               = $postgresql::params::manage_datadir,
  Boolean                                            $manage_logdir                = $postgresql::params::manage_logdir,
  Boolean                                            $manage_xlogdir               = $postgresql::params::manage_xlogdir,
  Postgresql::Pg_password_encryption                 $password_encryption          = $postgresql::params::password_encryption,
  Optional[Postgresql::Pg_password_encryption]       $pg_hba_auth_password_encryption = undef,
  Optional[String]                                   $extra_systemd_config         = $postgresql::params::extra_systemd_config,

  Hash[String, Hash]                                 $roles                        = {},
  Hash[String, Any]                                  $config_entries               = {},
  Postgresql::Pg_hba_rules                           $pg_hba_rules                 = {},

  Boolean                                            $backup_enable                = $postgresql::params::backup_enable,
  Hash                                               $backup_options               = {},
  Enum['pg_dump']                                    $backup_provider              = $postgresql::params::backup_provider,
) inherits postgresql::params {
  $_version = $postgresql::params::version

  # Reload has its own ordering, specified by other defines
  class { 'postgresql::server::reload':
    require => Class['postgresql::server::install'],
  }

  contain postgresql::server::install
  contain postgresql::server::initdb
  contain postgresql::server::config
  contain postgresql::server::service
  contain postgresql::server::passwd

  Class['postgresql::server::install']
  -> Class['postgresql::server::initdb']
  -> Class['postgresql::server::config']
  -> Class['postgresql::server::service']
  -> Class['postgresql::server::passwd']

  $roles.each |$rolename, $role| {
    postgresql::server::role { $rolename:
      * => $role,
    }
  }

  $config_entries.each |$entry, $value| {
    postgresql::server::config_entry { $entry:
      ensure => bool2str($value =~ Undef, 'absent', 'present'),
      value  => $value,
    }
  }

  $pg_hba_rules.each |String[1] $rule_name, Postgresql::Pg_hba_rule $rule| {
    postgresql::server::pg_hba_rule { $rule_name:
      * => $rule,
    }
  }

  if $backup_enable {
    case $backup_provider {
      'pg_dump': {
        class { 'postgresql::backup::pg_dump':
          * => $backup_options,
        }
      }
      default: {
        fail("Unsupported backup provider '${backup_provider}'.")
      }
    }
  }
}