mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	puppet: Add PostgreSQL 15 support.
Instead of copying over a mostly-unchanged `postgresql.conf`, we transition to deploying a `conf.d/zulip.conf` which contains the only material changes we made to the file, which were previously appended to the end. While shipping separate while `postgresql.conf` files for each supported version is useful if there is large variety in supported options between versions, there is not no such variation at current, and the burden of overriding the entire default configuration is that it must be keep up to date wit the package's version.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							2aae32f642
						
					
				
				
					commit
					f11350f789
				
			@@ -52,7 +52,8 @@ as well as those mentioned in the
 | 
				
			|||||||
[install](install.md#installer-options) documentation:
 | 
					[install](install.md#installer-options) documentation:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- `--postgresql-version`: Sets the version of PostgreSQL that will be
 | 
					- `--postgresql-version`: Sets the version of PostgreSQL that will be
 | 
				
			||||||
  installed. We currently support PostgreSQL 12, 13, and 14.
 | 
					  installed. We currently support PostgreSQL 12, 13, 14, and 15, with 15 being
 | 
				
			||||||
 | 
					  the default.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- `--postgresql-database-name=exampledbname`: With this option, you
 | 
					- `--postgresql-database-name=exampledbname`: With this option, you
 | 
				
			||||||
  can customize the default database name. If you do not set this. The
 | 
					  can customize the default database name. If you do not set this. The
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,13 @@
 | 
				
			|||||||
# PostgreSQL database details
 | 
					# PostgreSQL database details
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Starting with Zulip 3.0, Zulip supports a range of PostgreSQL
 | 
					Starting with Zulip 3.0, Zulip supports a range of PostgreSQL
 | 
				
			||||||
versions. PostgreSQL 14 is the current default for new installations;
 | 
					versions. PostgreSQL 15 is the current default for new installations;
 | 
				
			||||||
PostgreSQL 12, 13, and 14 are all supported.
 | 
					PostgreSQL 12, 13, 14, and 15 are all supported.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Previous versions of Zulip used whatever version of PostgreSQL was
 | 
					Previous versions of Zulip used whatever version of PostgreSQL was
 | 
				
			||||||
included with the base operating system (E.g. PostgreSQL 12 on Ubuntu
 | 
					included with the base operating system (E.g. PostgreSQL 12 on Ubuntu
 | 
				
			||||||
20.04). We recommend that installations currently using older
 | 
					20.04). We recommend that installations currently using older
 | 
				
			||||||
PostgreSQL releases [upgrade to PostgreSQL 14][upgrade-postgresql], as
 | 
					PostgreSQL releases [upgrade to PostgreSQL 15][upgrade-postgresql], as
 | 
				
			||||||
we may drop support for older PostgreSQL in a future release.
 | 
					we may drop support for older PostgreSQL in a future release.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[upgrade-postgresql]: upgrade.md#upgrading-postgresql
 | 
					[upgrade-postgresql]: upgrade.md#upgrading-postgresql
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -618,9 +618,9 @@ instructions for other supported platforms.
 | 
				
			|||||||
## Upgrading PostgreSQL
 | 
					## Upgrading PostgreSQL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Starting with Zulip 3.0, we use the latest available version of
 | 
					Starting with Zulip 3.0, we use the latest available version of
 | 
				
			||||||
PostgreSQL at installation time (currently version 14). Upgrades to
 | 
					PostgreSQL at installation time (currently version 15). Upgrades to
 | 
				
			||||||
the version of PostgreSQL are no longer linked to upgrades of the
 | 
					the version of PostgreSQL are no longer linked to upgrades of the
 | 
				
			||||||
distribution; that is, you may opt to upgrade to PostgreSQL 14 while
 | 
					distribution; that is, you may opt to upgrade to PostgreSQL 15 while
 | 
				
			||||||
running Ubuntu 20.04.
 | 
					running Ubuntu 20.04.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
To upgrade the version of PostgreSQL on the Zulip server:
 | 
					To upgrade the version of PostgreSQL on the Zulip server:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@ class zulip::profile::postgresql {
 | 
				
			|||||||
  include zulip::profile::base
 | 
					  include zulip::profile::base
 | 
				
			||||||
  include zulip::postgresql_base
 | 
					  include zulip::postgresql_base
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  $version = $zulip::postgresql_common::version
 | 
				
			||||||
  $work_mem = $zulip::common::total_memory_mb / 512
 | 
					  $work_mem = $zulip::common::total_memory_mb / 512
 | 
				
			||||||
  $shared_buffers = $zulip::common::total_memory_mb / 8
 | 
					  $shared_buffers = $zulip::common::total_memory_mb / 8
 | 
				
			||||||
  $effective_cache_size = $zulip::common::total_memory_mb * 10 / 32
 | 
					  $effective_cache_size = $zulip::common::total_memory_mb * 10 / 32
 | 
				
			||||||
@@ -29,14 +30,28 @@ class zulip::profile::postgresql {
 | 
				
			|||||||
    group  => 'postgres',
 | 
					    group  => 'postgres',
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  $postgresql_conf_file = "${zulip::postgresql_base::postgresql_confdir}/postgresql.conf"
 | 
					  if $version in ['12','13','14'] {
 | 
				
			||||||
  file { $postgresql_conf_file:
 | 
					    $postgresql_conf_file = "${zulip::postgresql_base::postgresql_confdir}/postgresql.conf"
 | 
				
			||||||
    ensure  => file,
 | 
					    file { $postgresql_conf_file:
 | 
				
			||||||
    require => Package[$zulip::postgresql_base::postgresql],
 | 
					      ensure  => file,
 | 
				
			||||||
    owner   => 'postgres',
 | 
					      require => Package[$zulip::postgresql_base::postgresql],
 | 
				
			||||||
    group   => 'postgres',
 | 
					      owner   => 'postgres',
 | 
				
			||||||
    mode    => '0644',
 | 
					      group   => 'postgres',
 | 
				
			||||||
    content => template("zulip/postgresql/${zulip::postgresql_common::version}/postgresql.conf.template.erb"),
 | 
					      mode    => '0644',
 | 
				
			||||||
 | 
					      content => template("zulip/postgresql/${version}/postgresql.conf.template.erb"),
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } elsif $version in ['15'] {
 | 
				
			||||||
 | 
					    $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")
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if $replication_primary != '' and $replication_user != '' {
 | 
					  if $replication_primary != '' and $replication_user != '' {
 | 
				
			||||||
@@ -47,8 +62,7 @@ class zulip::profile::postgresql {
 | 
				
			|||||||
          |-EOT
 | 
					          |-EOT
 | 
				
			||||||
      warning($message)
 | 
					      warning($message)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    # PostgreSQL uses the presence of a standby.signal file to trigger
 | 
					    # The presence of a standby.signal file triggers replication
 | 
				
			||||||
    # replication
 | 
					 | 
				
			||||||
    file { "${zulip::postgresql_base::postgresql_datadir}/standby.signal":
 | 
					    file { "${zulip::postgresql_base::postgresql_datadir}/standby.signal":
 | 
				
			||||||
      ensure  => file,
 | 
					      ensure  => file,
 | 
				
			||||||
      require => Package[$zulip::postgresql_base::postgresql],
 | 
					      require => Package[$zulip::postgresql_base::postgresql],
 | 
				
			||||||
@@ -57,11 +71,11 @@ class zulip::profile::postgresql {
 | 
				
			|||||||
      mode    => '0644',
 | 
					      mode    => '0644',
 | 
				
			||||||
      content => '',
 | 
					      content => '',
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  exec { $zulip::postgresql_base::postgresql_restart:
 | 
					    exec { $zulip::postgresql_base::postgresql_restart:
 | 
				
			||||||
    require     => Package[$zulip::postgresql_base::postgresql],
 | 
					      require     => Package[$zulip::postgresql_base::postgresql],
 | 
				
			||||||
    refreshonly => true,
 | 
					      refreshonly => true,
 | 
				
			||||||
    subscribe   => [ File[$postgresql_conf_file] ],
 | 
					      subscribe   => [ File[$postgresql_conf_file] ],
 | 
				
			||||||
  }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										63
									
								
								puppet/zulip/templates/postgresql/zulip.conf.template.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								puppet/zulip/templates/postgresql/zulip.conf.template.erb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
				
			|||||||
 | 
					<% if @listen_addresses != '' -%>
 | 
				
			||||||
 | 
					# Bind to specific address
 | 
				
			||||||
 | 
					listen_addresses = <%= @listen_addresses %>
 | 
				
			||||||
 | 
					<% end -%>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# This has an improved set of stopwords.
 | 
				
			||||||
 | 
					default_text_search_config = 'zulip.english_us_search'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Provide more comprehensive on-disk logs
 | 
				
			||||||
 | 
					logging_collector = on
 | 
				
			||||||
 | 
					log_directory = '/var/log/postgresql'
 | 
				
			||||||
 | 
					log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
 | 
				
			||||||
 | 
					log_rotation_age = 7d
 | 
				
			||||||
 | 
					log_rotation_size = 100MB
 | 
				
			||||||
 | 
					log_min_duration_statement = 500
 | 
				
			||||||
 | 
					log_line_prefix = '%m [%c]: [%l-1] '
 | 
				
			||||||
 | 
					log_checkpoints = on
 | 
				
			||||||
 | 
					log_lock_waits = on
 | 
				
			||||||
 | 
					log_temp_files = 0
 | 
				
			||||||
 | 
					log_autovacuum_min_duration = 100
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Adjust autovacuum for having many mostly-append-only tables
 | 
				
			||||||
 | 
					autovacuum_freeze_max_age = 2000000000
 | 
				
			||||||
 | 
					vacuum_freeze_min_age     = 1000000000
 | 
				
			||||||
 | 
					vacuum_freeze_table_age   = 1800000000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Performance settings
 | 
				
			||||||
 | 
					max_connections = 1000
 | 
				
			||||||
 | 
					maintenance_work_mem = <%= scope["zulip::profile::postgresql::maintenance_work_mem"] %>MB
 | 
				
			||||||
 | 
					effective_cache_size = <%= scope["zulip::profile::postgresql::effective_cache_size"] %>MB
 | 
				
			||||||
 | 
					work_mem = <%= scope["zulip::profile::postgresql::work_mem"] %>MB
 | 
				
			||||||
 | 
					shared_buffers = <%= scope["zulip::profile::postgresql::shared_buffers"] %>MB
 | 
				
			||||||
 | 
					wal_buffers = 4MB
 | 
				
			||||||
 | 
					checkpoint_completion_target = 0.7
 | 
				
			||||||
 | 
					<% if @random_page_cost != '' -%>
 | 
				
			||||||
 | 
					random_page_cost = <%= @random_page_cost %>
 | 
				
			||||||
 | 
					<% end -%>
 | 
				
			||||||
 | 
					<% if @effective_io_concurrency != '' -%>
 | 
				
			||||||
 | 
					effective_io_concurrency = <%= @effective_io_concurrency %>
 | 
				
			||||||
 | 
					<% end -%>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<% if @s3_backups_bucket != '' -%>
 | 
				
			||||||
 | 
					# Streaming backups and replication
 | 
				
			||||||
 | 
					archive_mode = on
 | 
				
			||||||
 | 
					archive_command = '/usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push %p'
 | 
				
			||||||
 | 
					restore_command = '/usr/local/bin/env-wal-g wal-fetch "%f" "%p"'
 | 
				
			||||||
 | 
					<% if @replication_primary != '' && @replication_user != '' -%>
 | 
				
			||||||
 | 
					primary_conninfo = 'host=<%= @replication_primary %> user=<%= @replication_user -%>
 | 
				
			||||||
 | 
					<% if @replication_password != '' %> password=<%= @replication_password %><% end -%>
 | 
				
			||||||
 | 
					<% if @ssl_mode != '' %> sslmode=<%= @ssl_mode %><% end -%>
 | 
				
			||||||
 | 
					'
 | 
				
			||||||
 | 
					<% end -%>
 | 
				
			||||||
 | 
					<% end -%>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<% if @ssl_cert_file != '' -%>
 | 
				
			||||||
 | 
					ssl_cert_file = '<%= @ssl_cert_file %>'		# (change requires restart)
 | 
				
			||||||
 | 
					<% end -%>
 | 
				
			||||||
 | 
					<% if @ssl_key_file != '' -%>
 | 
				
			||||||
 | 
					ssl_key_file = '<%= @ssl_key_file %>'		# (change requires restart)
 | 
				
			||||||
 | 
					<% end -%>
 | 
				
			||||||
 | 
					<% if @ssl_ca_file != '' -%>
 | 
				
			||||||
 | 
					ssl_ca_file = '<%= @ssl_ca_file %>'		# (change requires restart)
 | 
				
			||||||
 | 
					<% end -%>
 | 
				
			||||||
@@ -32,7 +32,7 @@ Options:
 | 
				
			|||||||
      Sets the PostgreSQL database name.
 | 
					      Sets the PostgreSQL database name.
 | 
				
			||||||
  --postgresql-database-user=zulip
 | 
					  --postgresql-database-user=zulip
 | 
				
			||||||
      Sets the PostgreSQL database user.
 | 
					      Sets the PostgreSQL database user.
 | 
				
			||||||
  --postgresql-version=14
 | 
					  --postgresql-version=15
 | 
				
			||||||
      Sets the version of PostgreSQL that will be installed.
 | 
					      Sets the version of PostgreSQL that will be installed.
 | 
				
			||||||
  --postgresql-missing-dictionaries
 | 
					  --postgresql-missing-dictionaries
 | 
				
			||||||
      Set postgresql.missing_dictionaries, which alters the initial database.  Use with
 | 
					      Set postgresql.missing_dictionaries, which alters the initial database.  Use with
 | 
				
			||||||
@@ -140,7 +140,7 @@ read -r -a ADDITIONAL_PACKAGES <<<"${ADDITIONAL_PACKAGES:-}"
 | 
				
			|||||||
# e.g. zulip::profile::app_frontend for a Zulip frontend server.
 | 
					# e.g. zulip::profile::app_frontend for a Zulip frontend server.
 | 
				
			||||||
PUPPET_CLASSES="${PUPPET_CLASSES:-zulip::profile::standalone}"
 | 
					PUPPET_CLASSES="${PUPPET_CLASSES:-zulip::profile::standalone}"
 | 
				
			||||||
VIRTUALENV_NEEDED="${VIRTUALENV_NEEDED:-yes}"
 | 
					VIRTUALENV_NEEDED="${VIRTUALENV_NEEDED:-yes}"
 | 
				
			||||||
POSTGRESQL_VERSION="${POSTGRESQL_VERSION:-14}"
 | 
					POSTGRESQL_VERSION="${POSTGRESQL_VERSION:-15}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -n "$SELF_SIGNED_CERT" ] && [ -n "$USE_CERTBOT" ]; then
 | 
					if [ -n "$SELF_SIGNED_CERT" ] && [ -n "$USE_CERTBOT" ]; then
 | 
				
			||||||
    set +x
 | 
					    set +x
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,7 @@ export LC_ALL=C.UTF-8
 | 
				
			|||||||
export LANG=C.UTF-8
 | 
					export LANG=C.UTF-8
 | 
				
			||||||
export LANGUAGE=C.UTF-8
 | 
					export LANGUAGE=C.UTF-8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UPGRADE_TO=${1:-14}
 | 
					UPGRADE_TO=${1:-15}
 | 
				
			||||||
UPGRADE_FROM=$(crudini --get /etc/zulip/zulip.conf postgresql version)
 | 
					UPGRADE_FROM=$(crudini --get /etc/zulip/zulip.conf postgresql version)
 | 
				
			||||||
ZULIP_PATH="$(dirname "$0")/../.."
 | 
					ZULIP_PATH="$(dirname "$0")/../.."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user