Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

installer: Use `puppet --write-catalog-summary` to determine classes.

Alex Vandiver9c0fd632bb8b
diff --git a/scripts/lib/install b/scripts/lib/install
index b5bb904404f..24dde24965a 100755
--- a/scripts/lib/install
+++ b/scripts/lib/install
@@ -325,57 +325,67 @@ fi
# Generate /etc/zulip/zulip.conf .
mkdir -p /etc/zulip
-if [ -z "$NO_OVERWRITE_SETTINGS" ] || ! [ -e "/etc/zulip/zulip.conf" ]; then
- (
- cat <<EOF
+has_class() {
+ grep -qx "$1" /var/lib/puppet/classes.txt
+}
+
+# puppet apply --noop fails unless the user that it _would_ chown
+# files to exists; https://tickets.puppetlabs.com/browse/PUP-3907
+#
+# The home directory here should match what's declared in base.pp.
+useradd -m zulip --home-dir /home/zulip
+if [ -n "$NO_OVERWRITE_SETTINGS" ] && [ -e "/etc/zulip/zulip.conf" ]; then
+ "$ZULIP_PATH"/scripts/zulip-puppet-apply --force --noop \
+ --write-catalog-summary \
+ --classfile=/var/lib/puppet/classes.txt \
+ >/dev/null
+else
+ # Write out more than we need, and remove sections that are not
+ # applicable to the classes that are actually necessary.
+ cat <<EOF > /etc/zulip/zulip.conf
[machine]
puppet_classes = $PUPPET_CLASSES
deploy_type = $DEPLOYMENT_TYPE
-EOF
-
- # Note: there are four dpkg-query outputs to consider:
- #
- # root@host# dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null
- # root@host# apt install rabbitmq-server
- # root@host# dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null
- # install ok installed
- # root@host# apt remove rabbitmq-server
- # root@host# dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null
- # deinstall ok config-files
- # root@host# apt purge rabbitmq-server
- # root@host# dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null
- # unknown ok not-installed
- #
- # (There are more possibilities in the case of dpkg errors.) Here
- # we are checking for either empty or not-installed.
- if ! dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null | grep -vq ' not-installed$'; then
- cat <<EOF
-[rabbitmq]
-nodename = zulip@localhost
+[postgresql]
+version = $POSTGRES_VERSION
EOF
- fi
- if [ -n "$USE_CERTBOT" ]; then
- cat <<EOF
+ if [ -n "$USE_CERTBOT" ]; then
+ crudini --set /etc/zulip/zulip.conf certbot auto_renew yes
+ fi
-[certbot]
-auto_renew = yes
-EOF
- fi
+ "$ZULIP_PATH"/scripts/zulip-puppet-apply --force --noop \
+ --write-catalog-summary \
+ --classfile=/var/lib/puppet/classes.txt \
+ >/dev/null
- case ",$PUPPET_CLASSES," in
- *,zulip::voyager,* | *,zulip::postgres_appdb_tuned,*)
- if [ "$package_system" = apt ]; then
- cat <<EOF
+ if ! has_class "zulip::postgres_common" || [ "$package_system" != apt ]; then
+ crudini --del /etc/zulip/zulip.conf postgresql
+ fi
-[postgresql]
-version = $POSTGRES_VERSION
+ # Note: there are four dpkg-query outputs to consider:
+ #
+ # root@host# dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null
+ # root@host# apt install rabbitmq-server
+ # root@host# dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null
+ # install ok installed
+ # root@host# apt remove rabbitmq-server
+ # root@host# dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null
+ # deinstall ok config-files
+ # root@host# apt purge rabbitmq-server
+ # root@host# dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null
+ # unknown ok not-installed
+ #
+ # (There are more possibilities in the case of dpkg errors.) Here
+ # we are checking for either empty or not-installed.
+ if ! dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null | grep -vq ' not-installed$'; then
+ cat <<EOF >>/etc/zulip/zulip.conf
+
+[rabbitmq]
+nodename = zulip@localhost
EOF
- fi
- ;;
- esac
- ) > /etc/zulip/zulip.conf
+ fi
fi
case ",$PUPPET_CLASSES," in