diff --git a/custom_zulip_files/puppet/zulip/files/postgresql/process_fts_updates b/custom_zulip_files/puppet/zulip/files/postgresql/process_fts_updates index c1656c5..836ba3b 100755 --- a/custom_zulip_files/puppet/zulip/files/postgresql/process_fts_updates +++ b/custom_zulip_files/puppet/zulip/files/postgresql/process_fts_updates @@ -44,7 +44,7 @@ try: os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings' from django.conf import settings remote_postgres_host = settings.REMOTE_POSTGRES_HOST -except ImportError, e: +except ImportError as e: # process_fts_updates also supports running locally on a remote # postgres server; in that case, one can just connect to localhost remote_postgres_host = '' diff --git a/custom_zulip_files/puppet/zulip/manifests/app_frontend_base.pp b/custom_zulip_files/puppet/zulip/manifests/app_frontend_base.pp index 1edba07..16741a3 100644 --- a/custom_zulip_files/puppet/zulip/manifests/app_frontend_base.pp +++ b/custom_zulip_files/puppet/zulip/manifests/app_frontend_base.pp @@ -133,4 +133,13 @@ class zulip::app_frontend_base { file { "/etc/cron.d/email-mirror": ensure => absent, } + file { "/usr/lib/nagios/plugins/zulip_app_frontend": + require => Package[nagios-plugins-basic], + recurse => true, + purge => true, + owner => "root", + group => "root", + mode => 755, + source => "puppet:///modules/zulip/nagios_plugins/zulip_app_frontend", + } } diff --git a/custom_zulip_files/puppet/zulip/manifests/base.pp b/custom_zulip_files/puppet/zulip/manifests/base.pp index 40a226a..85f1f59 100644 --- a/custom_zulip_files/puppet/zulip/manifests/base.pp +++ b/custom_zulip_files/puppet/zulip/manifests/base.pp @@ -10,6 +10,8 @@ class zulip::base { "ipython", # Used in scripts "netcat", + # Nagios plugins; needed to ensure /var/lib/nagios_plugins exists + "nagios-plugins-basic", ] package { $base_packages: ensure => "installed" } @@ -81,4 +83,14 @@ class zulip::base { group => 'zulip', mode => 640, } + + file { "/usr/lib/nagios/plugins/zulip_base": + require => Package[nagios-plugins-basic], + recurse => true, + purge => true, + owner => "root", + group => "root", + mode => 755, + source => "puppet:///modules/zulip/nagios_plugins/zulip_base", + } } diff --git a/custom_zulip_files/puppet/zulip/manifests/postgres_appdb_base.pp b/custom_zulip_files/puppet/zulip/manifests/postgres_appdb_base.pp index b97dba2..437ddf8 100644 --- a/custom_zulip_files/puppet/zulip/manifests/postgres_appdb_base.pp +++ b/custom_zulip_files/puppet/zulip/manifests/postgres_appdb_base.pp @@ -56,5 +56,14 @@ class zulip::postgres_appdb_base { mode => 644, source => "puppet:///modules/zulip/postgresql/zulip_english.stop", } + file { "/usr/lib/nagios/plugins/zulip_postgres_appdb": + require => Package[nagios-plugins-basic], + recurse => true, + purge => true, + owner => "root", + group => "root", + mode => 755, + source => "puppet:///modules/zulip/nagios_plugins/zulip_postgres_appdb", + } } diff --git a/custom_zulip_files/puppet/zulip/manifests/postgres_common.pp b/custom_zulip_files/puppet/zulip/manifests/postgres_common.pp index f1d283c..087c5f2 100644 --- a/custom_zulip_files/puppet/zulip/manifests/postgres_common.pp +++ b/custom_zulip_files/puppet/zulip/manifests/postgres_common.pp @@ -23,4 +23,13 @@ class zulip::postgres_common { command => "/usr/bin/dpkg-divert --rename --divert /etc/logrotate.d/postgresql-common.disabled --add /etc/logrotate.d/postgresql-common", creates => '/etc/logrotate.d/postgresql-common.disabled', } + file { "/usr/lib/nagios/plugins/zulip_postgres_common": + require => Package[nagios-plugins-basic], + recurse => true, + purge => true, + owner => "root", + group => "root", + mode => 755, + source => "puppet:///modules/zulip/nagios_plugins/zulip_postgres_common", + } } diff --git a/custom_zulip_files/scripts/lib/install b/custom_zulip_files/scripts/lib/install index 283f16a..abd688e 100755 --- a/custom_zulip_files/scripts/lib/install +++ b/custom_zulip_files/scripts/lib/install @@ -5,10 +5,10 @@ set -xe APT_OPTIONS="${APT_OPTIONS:-}" # Install additional packages using apt ADDITIONAL_PACKAGES=${ADDITIONAL_PACKAGES:-} -# Call the default type "voyager", for docker it's "dockervoyager" +# Call the default type "voyager", for docker it's the same DEPLOYMENT_TYPE="${DEPLOYMENT_TYPE:-voyager}" -# Can be for example "zulip::dockervoyager" or "zulip::voyager" -VOYAGER_CLASS="${VOYAGER_CLASS:-zulip::voyager}" +# Can be for example "dockervoyager" or voyager +PUPPET_CLASSES="${PUPPET_CLASSES:-zulip::voyager}" # Assumes we've already been untarred @@ -26,13 +26,13 @@ apt-get install -y puppet git python $ADDITIONAL_PACKAGES mkdir -p /etc/zulip -echo -e "[machine]\npuppet_classes = $VOYAGER_CLASS\ndeploy_type = voyager" > /etc/zulip/zulip.conf +echo -e "[machine]\npuppet_classes = $PUPPET_CLASSES\ndeploy_type = $DEPLOYMENT_TYPE" > /etc/zulip/zulip.conf /root/zulip/scripts/zulip-puppet-apply -f # These server restarting bits should be moveable into puppet-land, ideally apt-get -y upgrade # Don't start services when deploying in docker aka dockervoyager -if [ "$DEPLOYMENT_TYPE" != "dockervoyager" ]; then +if [ "$DEPLOYMENT_TYPE" = "voyager" ]; then if [ -e "/etc/init.d/nginx" ]; then # Check nginx was configured properly now that we've installed it. # Most common failure mode is certs not having been installed. @@ -53,12 +53,13 @@ if [ "$DEPLOYMENT_TYPE" != "dockervoyager" ]; then fi cp -a /root/zulip/zproject/local_settings_template.py /etc/zulip/settings.py ln -nsf /etc/zulip/settings.py /root/zulip/zproject/local_settings.py -if [ "$DEPLOYMENT_TYPE" != "dockervoyager" ]; then +if [ "$DEPLOYMENT_TYPE" = "voyager" ]; then + # Configure rabbitmq /root/zulip/scripts/setup/configure-rabbitmq - + # Init postgres database /root/zulip/scripts/setup/postgres-init-db else - echo; echo "Skipping service starts, chosen Deployment Type is \'$DEPLOYMENT_TYPE\'." + echo; echo "Skipping rabbitmq configure and postgres init, because DEPLOYMENT_TYPE is not 'voyager', is '$DEPLOYMENT_TYPE'." fi deploy_path=$(/root/zulip/zulip_tools.py make_deploy_path) @@ -67,11 +68,7 @@ ln -nsf /home/zulip/deployments/next /root/zulip ln -nsf "$deploy_path" /home/zulip/deployments/next ln -nsf "$deploy_path" /home/zulip/deployments/current ln -nsf /etc/zulip/settings.py "$deploy_path"/zproject/local_settings.py -if [ "$DEPLOYMENT_TYPE" == "dockervoyager" ]; then - # We generate the static files later in the entrypoint.sh we don't have the - # static files right now, so just create the folder to fix the error with "cp ..." - mkdir -p "$deploy_path"/prod-static/serve -fi +mkdir -p "$deploy_path"/prod-static/serve cp -rT "$deploy_path"/prod-static/serve /home/zulip/prod-static chown -R zulip:zulip /home/zulip /var/log/zulip /etc/zulip/settings.py # Allow this to fail, if there is no supervisor running in a docker install diff --git a/custom_zulip_files/scripts/setup/configure-rabbitmq b/custom_zulip_files/scripts/setup/configure-rabbitmq index bee7d48..2bda3b2 100755 --- a/custom_zulip_files/scripts/setup/configure-rabbitmq +++ b/custom_zulip_files/scripts/setup/configure-rabbitmq @@ -2,8 +2,7 @@ # # Delete the "guest" default user and replace it with a Zulip user # with a real password -set -e -set -x +set -ex RABBITMQ_USERNAME=$("$(dirname "$0")/../../bin/get-django-setting" RABBITMQ_USERNAME) RABBITMQ_PASSWORD=$("$(dirname "$0")/../../bin/get-django-setting" RABBITMQ_PASSWORD) diff --git a/custom_zulip_files/scripts/setup/postgres-init-db b/custom_zulip_files/scripts/setup/postgres-init-db index 9ce8f04..69ac656 100755 --- a/custom_zulip_files/scripts/setup/postgres-init-db +++ b/custom_zulip_files/scripts/setup/postgres-init-db @@ -1,6 +1,5 @@ #!/bin/bash -set -e -set -x +set -ex # A bit of a helper variable, default is voyager DEPLOYMENT_TYPE="${DEPLOYMENT_TYPE:-voyager}" @@ -44,7 +43,7 @@ CREATE USER zulip; ALTER ROLE zulip SET search_path TO zulip,public; EOF # Never drop the database when run from docker! -# In Docker we have to run this script everytime we start the container, so don't drop.. +# In Docker we have to run this script everytime we start the container, so don't drop. if [ "$DEPLOYMENT_TYPE" != "dockervoyager" ]; then su "$POSTGRES_USER" -c "$POSTGRES_COMMAND" <