puppet: Standardize what values are bools, and what true is.

For `no_serve_uploads`, `http_only`, which previously specified
"non-empty" to enable, this tightens what values are true.  For
`pgroonga` and `queue_workers_multiprocess`, this broadens the
possible values from `enabled`, and `true` respectively.
This commit is contained in:
Alex Vandiver
2022-01-05 10:45:12 -08:00
committed by Alex Vandiver
parent 1e672e4d82
commit 2c5fc1827c
8 changed files with 56 additions and 29 deletions

View File

@@ -538,6 +538,20 @@ the system and deployment; `/etc/zulip/settings.py` is used to
configure the application itself. The `zulip.conf` sections and configure the application itself. The `zulip.conf` sections and
settings are described below. settings are described below.
When a setting refers to "set to true" or "set to false", the values
`true` and `false` are canonical, but any of the following values will
be considered "true", case-insensitively:
- 1
- y
- t
- yes
- true
- enable
- enabled
Any other value (including the empty string) is considered false.
### `[machine]` ### `[machine]`
#### `puppet_classes` #### `puppet_classes`
@@ -560,8 +574,7 @@ you will need to add **`zulip::apache_sso`** to the list.
#### `pgroonga` #### `pgroonga`
Set to the string `enabled` if enabling the [multi-language PGroonga Set to true if enabling the [multi-language PGroonga search
search
extension](../subsystems/full-text-search.html#multi-language-full-text-search). extension](../subsystems/full-text-search.html#multi-language-full-text-search).
### `[deployment]` ### `[deployment]`
@@ -591,9 +604,9 @@ repository](../production/upgrade-or-modify.html#upgrading-from-a-git-repository
#### `http_only` #### `http_only`
If set to non-empty, [configures Zulip to allow HTTP If set to true, [configures Zulip to allow HTTP access][using-http];
access][using-http]; use if Zulip is deployed behind a reverse proxy use if Zulip is deployed behind a reverse proxy that is handling
that is handling SSL/TLS termination. SSL/TLS termination.
#### `nginx_listen_port` #### `nginx_listen_port`
@@ -603,7 +616,7 @@ Set to the port number if you [prefer to listen on a port other than
#### `no_serve_uploads` #### `no_serve_uploads`
To enable the [the S3 uploads backend][s3-uploads], one needs to both To enable the [the S3 uploads backend][s3-uploads], one needs to both
configure `settings.py` and set this to 'true' to configure configure `settings.py` and set this to true to configure
`nginx`. Remove this field to return to the local uploads backend (any `nginx`. Remove this field to return to the local uploads backend (any
non-empty value is currently equivalent to true). non-empty value is currently equivalent to true).
@@ -618,10 +631,11 @@ mode). The calculation is based on whether the system has enough
memory (currently 3.5GiB) to run a single-server Zulip installation in memory (currently 3.5GiB) to run a single-server Zulip installation in
the multiprocess mode. the multiprocess mode.
Set to `true` or `false` to override the automatic calculation. This Set explicitly to true or false to override the automatic
override is useful both Docker systems (where the above algorithm calculation. This override is useful both Docker systems (where the
might see the host's memory, not the container's) and/or when using above algorithm might see the host's memory, not the container's)
remote servers for postgres, memcached, redis, and RabbitMQ. and/or when using remote servers for postgres, memcached, redis, and
RabbitMQ.
#### `rolling_restart` #### `rolling_restart`
@@ -670,10 +684,10 @@ setting](https://www.postgresql.org/docs/current/runtime-config-query.html#GUC-R
#### `replication` #### `replication`
Set to non-empty to enable replication to enable [log shipping Set to true to enable replication to enable [log shipping replication
replication between PostgreSQL servers](#postgresql-warm-standby). between PostgreSQL servers](#postgresql-warm-standby). This should be
This should be enabled on the primary, as well as any replicas, and enabled on the primary, as well as any replicas, and further requires
further requires configuration of configuration of
[wal-g](../production/export-and-import.html#backup-details). [wal-g](../production/export-and-import.html#backup-details).
#### `replication_primary` #### `replication_primary`

View File

@@ -141,7 +141,15 @@ except ImportError:
config_file = configparser.RawConfigParser() config_file = configparser.RawConfigParser()
config_file.read("/etc/zulip/zulip.conf") config_file.read("/etc/zulip/zulip.conf")
if config_file.has_option("machine", "pgroonga"): if get_config(config_file, "machine", "pgroonga", "false").lower() in [
"1",
"y",
"t",
"yes",
"true",
"enable",
"enabled",
]:
USING_PGROONGA = True USING_PGROONGA = True
pg_args["user"] = get_config(config_file, "postgresql", "database_user", "zulip") pg_args["user"] = get_config(config_file, "postgresql", "database_user", "zulip")

View File

@@ -5,7 +5,12 @@ module Puppet::Parser::Functions
zulip_conf_path = lookupvar("zulip_conf_path") zulip_conf_path = lookupvar("zulip_conf_path")
output = `/usr/bin/crudini --get #{zulip_conf_path} #{joined} 2>&1`; result = $?.success? output = `/usr/bin/crudini --get #{zulip_conf_path} #{joined} 2>&1`; result = $?.success?
if result if result
output.strip() if [true, false].include? default
# If the default is a bool, coerce into a bool
['1','y','t','true','yes','enable','enabled'].include? output.strip.downcase
else
output.strip
end
else else
default default
end end

View File

@@ -73,7 +73,7 @@ class zulip::app_frontend_base {
# multiprocess. Multiprocess scales much better, but requires more # multiprocess. Multiprocess scales much better, but requires more
# RAM; we just auto-detect based on available system RAM. # RAM; we just auto-detect based on available system RAM.
$queues_multiprocess_default = $zulip::common::total_memory_mb > 3500 $queues_multiprocess_default = $zulip::common::total_memory_mb > 3500
$queues_multiprocess = Boolean(zulipconf('application_server', 'queue_workers_multiprocess', $queues_multiprocess_default)) $queues_multiprocess = zulipconf('application_server', 'queue_workers_multiprocess', $queues_multiprocess_default)
$queues = [ $queues = [
'deferred_work', 'deferred_work',
'digest_emails', 'digest_emails',

View File

@@ -39,8 +39,12 @@ class zulip::nginx {
# For installations using S3 to serve uploaded files, we want Django # For installations using S3 to serve uploaded files, we want Django
# to handle the /serve_uploads and /user_avatars routes, so that it # to handle the /serve_uploads and /user_avatars routes, so that it
# can serve a redirect (after doing authentication, for uploads). # can serve a redirect (after doing authentication, for uploads).
$no_serve_uploads = zulipconf('application_server', 'no_serve_uploads', '') $no_serve_uploads = zulipconf('application_server', 'no_serve_uploads', false)
if $no_serve_uploads == '' { if $no_serve_uploads {
file { '/etc/nginx/zulip-include/app.d/uploads-internal.conf':
ensure => absent,
}
} else {
file { '/etc/nginx/zulip-include/app.d/uploads-internal.conf': file { '/etc/nginx/zulip-include/app.d/uploads-internal.conf':
ensure => file, ensure => file,
require => Package[$zulip::common::nginx], require => Package[$zulip::common::nginx],
@@ -50,10 +54,6 @@ class zulip::nginx {
notify => Service['nginx'], notify => Service['nginx'],
source => 'puppet:///modules/zulip/nginx/zulip-include-maybe/uploads-internal.conf', source => 'puppet:///modules/zulip/nginx/zulip-include-maybe/uploads-internal.conf',
} }
} else {
file { '/etc/nginx/zulip-include/app.d/uploads-internal.conf':
ensure => absent,
}
} }
# TODO/compatibility: Removed 2021-04 in Zulip 4.0; these lines can # TODO/compatibility: Removed 2021-04 in Zulip 4.0; these lines can

View File

@@ -72,8 +72,8 @@ class zulip::postgresql_base {
source => 'puppet:///modules/zulip/nagios_plugins/zulip_postgresql', source => 'puppet:///modules/zulip/nagios_plugins/zulip_postgresql',
} }
$pgroonga = zulipconf('machine', 'pgroonga', '') $pgroonga = zulipconf('machine', 'pgroonga', false)
if $pgroonga == 'enabled' { if $pgroonga {
# Needed for optional our full text search system # Needed for optional our full text search system
# Removed 2020-12 in version 4.0; these lines can be removed when # Removed 2020-12 in version 4.0; these lines can be removed when

View File

@@ -4,8 +4,8 @@ class zulip::profile::app_frontend {
include zulip::app_frontend_base include zulip::app_frontend_base
include zulip::app_frontend_once include zulip::app_frontend_once
$nginx_http_only = zulipconf('application_server', 'http_only', undef) $nginx_http_only = zulipconf('application_server', 'http_only', false)
if $nginx_http_only != '' { if $nginx_http_only {
$nginx_listen_port = zulipconf('application_server', 'nginx_listen_port', 80) $nginx_listen_port = zulipconf('application_server', 'nginx_listen_port', 80)
} else { } else {
$nginx_listen_port = zulipconf('application_server', 'nginx_listen_port', 443) $nginx_listen_port = zulipconf('application_server', 'nginx_listen_port', 443)

View File

@@ -1,4 +1,4 @@
<% if @nginx_http_only != '' -%> <% if @nginx_http_only -%>
<% else -%> <% else -%>
server { server {
listen 80; listen 80;
@@ -15,7 +15,7 @@ server {
include /etc/nginx/zulip-include/upstreams; include /etc/nginx/zulip-include/upstreams;
server { server {
<% if @nginx_http_only != '' -%> <% if @nginx_http_only -%>
listen <%= @nginx_listen_port %>; listen <%= @nginx_listen_port %>;
listen [::]:<%= @nginx_listen_port %>; listen [::]:<%= @nginx_listen_port %>;
<% else -%> <% else -%>