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
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]`
#### `puppet_classes`
@ -560,8 +574,7 @@ you will need to add **`zulip::apache_sso`** to the list.
#### `pgroonga`
Set to the string `enabled` if enabling the [multi-language PGroonga
search
Set to true if enabling the [multi-language PGroonga search
extension](../subsystems/full-text-search.html#multi-language-full-text-search).
### `[deployment]`
@ -591,9 +604,9 @@ repository](../production/upgrade-or-modify.html#upgrading-from-a-git-repository
#### `http_only`
If set to non-empty, [configures Zulip to allow HTTP
access][using-http]; use if Zulip is deployed behind a reverse proxy
that is handling SSL/TLS termination.
If set to true, [configures Zulip to allow HTTP access][using-http];
use if Zulip is deployed behind a reverse proxy that is handling
SSL/TLS termination.
#### `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`
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
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
the multiprocess mode.
Set to `true` or `false` to override the automatic calculation. This
override is useful both Docker systems (where the above algorithm
might see the host's memory, not the container's) and/or when using
remote servers for postgres, memcached, redis, and RabbitMQ.
Set explicitly to true or false to override the automatic
calculation. This override is useful both Docker systems (where the
above algorithm might see the host's memory, not the container's)
and/or when using remote servers for postgres, memcached, redis, and
RabbitMQ.
#### `rolling_restart`
@ -670,10 +684,10 @@ setting](https://www.postgresql.org/docs/current/runtime-config-query.html#GUC-R
#### `replication`
Set to non-empty to enable replication to enable [log shipping
replication between PostgreSQL servers](#postgresql-warm-standby).
This should be enabled on the primary, as well as any replicas, and
further requires configuration of
Set to true to enable replication to enable [log shipping replication
between PostgreSQL servers](#postgresql-warm-standby). This should be
enabled on the primary, as well as any replicas, and further requires
configuration of
[wal-g](../production/export-and-import.html#backup-details).
#### `replication_primary`

View File

@ -141,7 +141,15 @@ except ImportError:
config_file = configparser.RawConfigParser()
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
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")
output = `/usr/bin/crudini --get #{zulip_conf_path} #{joined} 2>&1`; result = $?.success?
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
default
end

View File

@ -73,7 +73,7 @@ class zulip::app_frontend_base {
# multiprocess. Multiprocess scales much better, but requires more
# RAM; we just auto-detect based on available system RAM.
$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 = [
'deferred_work',
'digest_emails',

View File

@ -39,8 +39,12 @@ class zulip::nginx {
# For installations using S3 to serve uploaded files, we want Django
# to handle the /serve_uploads and /user_avatars routes, so that it
# can serve a redirect (after doing authentication, for uploads).
$no_serve_uploads = zulipconf('application_server', 'no_serve_uploads', '')
if $no_serve_uploads == '' {
$no_serve_uploads = zulipconf('application_server', 'no_serve_uploads', false)
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':
ensure => file,
require => Package[$zulip::common::nginx],
@ -50,10 +54,6 @@ class zulip::nginx {
notify => Service['nginx'],
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

View File

@ -72,8 +72,8 @@ class zulip::postgresql_base {
source => 'puppet:///modules/zulip/nagios_plugins/zulip_postgresql',
}
$pgroonga = zulipconf('machine', 'pgroonga', '')
if $pgroonga == 'enabled' {
$pgroonga = zulipconf('machine', 'pgroonga', false)
if $pgroonga {
# Needed for optional our full text search system
# 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_once
$nginx_http_only = zulipconf('application_server', 'http_only', undef)
if $nginx_http_only != '' {
$nginx_http_only = zulipconf('application_server', 'http_only', false)
if $nginx_http_only {
$nginx_listen_port = zulipconf('application_server', 'nginx_listen_port', 80)
} else {
$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 -%>
server {
listen 80;
@ -15,7 +15,7 @@ server {
include /etc/nginx/zulip-include/upstreams;
server {
<% if @nginx_http_only != '' -%>
<% if @nginx_http_only -%>
listen <%= @nginx_listen_port %>;
listen [::]:<%= @nginx_listen_port %>;
<% else -%>