Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
117 lines
4.9 KiB
Puppet
117 lines
4.9 KiB
Puppet
# @summary Extends postgresql_base by tuning the configuration.
|
|
class zulip::profile::postgresql(Boolean $start = true) {
|
|
include zulip::profile::base
|
|
include zulip::postgresql_base
|
|
include zulip::systemd_daemon_reload
|
|
|
|
$version = $zulip::postgresql_common::version
|
|
|
|
if defined(Class['zulip::app_frontend_base']) {
|
|
$total_postgres_memory_mb = zulipconf('postgresql', 'memory', $zulip::common::total_memory_mb / 2)
|
|
} else {
|
|
$total_postgres_memory_mb = zulipconf('postgresql', 'memory', $zulip::common::total_memory_mb)
|
|
}
|
|
$work_mem = zulipconf('postgresql', 'work_mem', sprintf('%dMB', $total_postgres_memory_mb / 256))
|
|
$shared_buffers = zulipconf('postgresql', 'shared_buffers', sprintf('%dMB', $total_postgres_memory_mb / 4))
|
|
$effective_cache_size = zulipconf('postgresql', 'effective_cache_size', sprintf('%dMB', $total_postgres_memory_mb * 3 / 4))
|
|
$maintenance_work_mem = zulipconf('postgresql', 'maintenance_work_mem', sprintf('%dMB', min(2048, $total_postgres_memory_mb / 8)))
|
|
|
|
$max_worker_processes = zulipconf('postgresql', 'max_worker_processes', undef)
|
|
$max_parallel_workers_per_gather = zulipconf('postgresql', 'max_parallel_workers_per_gather', undef)
|
|
$max_parallel_workers = zulipconf('postgresql', 'max_parallel_workers', undef)
|
|
$max_parallel_maintenance_workers = zulipconf('postgresql', 'max_parallel_maintenance_workers', undef)
|
|
|
|
$wal_buffers = zulipconf('postgresql', 'wal_buffers', undef)
|
|
$min_wal_size = zulipconf('postgresql', 'min_wal_size', undef)
|
|
$max_wal_size = zulipconf('postgresql', 'max_wal_size', undef)
|
|
$random_page_cost = zulipconf('postgresql', 'random_page_cost', '1.1')
|
|
$effective_io_concurrency = zulipconf('postgresql', 'effective_io_concurrency', undef)
|
|
|
|
$listen_addresses = zulipconf('postgresql', 'listen_addresses', undef)
|
|
|
|
$s3_backups_bucket = zulipsecret('secrets', 's3_backups_bucket', '')
|
|
$replication_primary = zulipconf('postgresql', 'replication_primary', undef)
|
|
$replication_user = zulipconf('postgresql', 'replication_user', undef)
|
|
$replication_password = zulipsecret('secrets', 'postgresql_replication_password', '')
|
|
|
|
$ssl_cert_file = zulipconf('postgresql', 'ssl_cert_file', undef)
|
|
$ssl_key_file = zulipconf('postgresql', 'ssl_key_file', undef)
|
|
$ssl_ca_file = zulipconf('postgresql', 'ssl_ca_file', undef)
|
|
$ssl_mode = zulipconf('postgresql', 'ssl_mode', undef)
|
|
|
|
file { $zulip::postgresql_base::postgresql_confdirs:
|
|
ensure => directory,
|
|
owner => 'postgres',
|
|
group => 'postgres',
|
|
}
|
|
|
|
if $version in ['14'] {
|
|
$postgresql_conf_file = "${zulip::postgresql_base::postgresql_confdir}/postgresql.conf"
|
|
file { $postgresql_conf_file:
|
|
ensure => file,
|
|
require => Package[$zulip::postgresql_base::postgresql],
|
|
owner => 'postgres',
|
|
group => 'postgres',
|
|
mode => '0644',
|
|
content => template("zulip/postgresql/${version}/postgresql.conf.template.erb"),
|
|
}
|
|
} elsif $version in ['15', '16', '17', '18'] {
|
|
$postgresql_conf_file = "${zulip::postgresql_base::postgresql_confdir}/conf.d/zulip.conf"
|
|
file { $postgresql_conf_file:
|
|
ensure => file,
|
|
require => Package[$zulip::postgresql_base::postgresql],
|
|
owner => 'postgres',
|
|
group => 'postgres',
|
|
mode => '0644',
|
|
content => template('zulip/postgresql/zulip.conf.template.erb'),
|
|
}
|
|
} else {
|
|
fail("PostgreSQL ${version} not supported")
|
|
}
|
|
|
|
# PostgreSQL 18's io_method = io_uring requires a larger
|
|
# RLIMIT_MEMLOCK than systemd's default on Linux 6.14 and newer
|
|
if $facts['os']['family'] == 'Debian' {
|
|
file { '/etc/systemd/system/postgresql@.service.d':
|
|
ensure => directory,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0755',
|
|
}
|
|
file { '/etc/systemd/system/postgresql@.service.d/zulip.conf':
|
|
ensure => file,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0644',
|
|
source => 'puppet:///modules/zulip/postgresql/postgresql@.service.d/zulip.conf',
|
|
notify => [Exec['reload systemd'], Service['postgresql']],
|
|
}
|
|
}
|
|
|
|
if $replication_primary != undef and $replication_user != undef {
|
|
# The presence of a standby.signal file triggers replication
|
|
file { "${zulip::postgresql_base::postgresql_datadir}/standby.signal":
|
|
ensure => file,
|
|
require => Package[$zulip::postgresql_base::postgresql],
|
|
before => Service['postgresql'],
|
|
owner => 'postgres',
|
|
group => 'postgres',
|
|
mode => '0644',
|
|
content => '',
|
|
}
|
|
}
|
|
|
|
$backups_s3_bucket = zulipsecret('secrets', 's3_backups_bucket', '')
|
|
$backups_directory = zulipconf('postgresql', 'backups_directory', '')
|
|
if $backups_s3_bucket != '' or $backups_directory != '' {
|
|
$require = [File['/usr/local/bin/env-wal-g'], Package[$zulip::postgresql_base::postgresql]]
|
|
} else {
|
|
$require = [Package[$zulip::postgresql_base::postgresql]]
|
|
}
|
|
service { 'postgresql':
|
|
ensure => $start,
|
|
require => $require + [Exec['reload systemd']],
|
|
subscribe => [ File[$postgresql_conf_file] ],
|
|
}
|
|
}
|