From cb24f93bba2afc179a24cdce5b71e7bea9d0bc06 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 5 Jan 2022 10:45:12 -0800 Subject: [PATCH] puppet: Make zulipconf() understand coercion to bool. If the default is a bool, coerce the value into a bool as well. For backwards compatibility, this does not adjust any existing callsites. `queue_workers_multiprocess` is the only setting which is passed a bool default, but it was already documented to take `true` or `false`; simplify it to no longer add the now-unnecessary Boolean conversion. (cherry picked from part of commit 2c5fc1827cb460030c24f7638abbc4d6a246a580) --- puppet/zulip/lib/puppet/parser/functions/zulipconf.rb | 7 ++++++- puppet/zulip/manifests/app_frontend_base.pp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/puppet/zulip/lib/puppet/parser/functions/zulipconf.rb b/puppet/zulip/lib/puppet/parser/functions/zulipconf.rb index 8946a8ffea..83f004c148 100644 --- a/puppet/zulip/lib/puppet/parser/functions/zulipconf.rb +++ b/puppet/zulip/lib/puppet/parser/functions/zulipconf.rb @@ -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 diff --git a/puppet/zulip/manifests/app_frontend_base.pp b/puppet/zulip/manifests/app_frontend_base.pp index 244cc08f96..ebd60f3da4 100644 --- a/puppet/zulip/manifests/app_frontend_base.pp +++ b/puppet/zulip/manifests/app_frontend_base.pp @@ -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',