mirror of https://github.com/zulip/zulip.git
[manual] Switch over to new /etc/zulip/zulip.conf config file
Run the following commands as root before deploying this branch: # /root/zulip/tools/migrate-server-config # rm /etc/zulip/machinetype /etc/zulip/server /etc/zulip/local /etc/humbug-machinetype /etc/humbug-server /etc/humbug-local (imported from commit aa7dcc50d2f4792ce33834f14761e76512fca252)
This commit is contained in:
parent
e9bd56b5a0
commit
787215d743
|
@ -28,14 +28,6 @@ class zulip-internal::base {
|
||||||
source => 'puppet:///modules/zulip-internal/root_authorized_keys',
|
source => 'puppet:///modules/zulip-internal/root_authorized_keys',
|
||||||
}
|
}
|
||||||
|
|
||||||
# This is just an empty file. It's used by the app to test if it's running
|
|
||||||
# in production.
|
|
||||||
file { '/etc/zulip/server':
|
|
||||||
ensure => file,
|
|
||||||
mode => 644,
|
|
||||||
content => '',
|
|
||||||
}
|
|
||||||
|
|
||||||
file { '/usr/local/sbin/zulip-ec2-configure-interfaces':
|
file { '/usr/local/sbin/zulip-ec2-configure-interfaces':
|
||||||
ensure => file,
|
ensure => file,
|
||||||
mode => 755,
|
mode => 755,
|
||||||
|
|
|
@ -1,14 +1,2 @@
|
||||||
class zulip-internal ($machinetype) {
|
class zulip-internal {
|
||||||
class { "zulip-internal::$machinetype": }
|
|
||||||
|
|
||||||
file { '/etc/zulip/machinetype':
|
|
||||||
ensure => file,
|
|
||||||
mode => 644,
|
|
||||||
content => "$machinetype\n",
|
|
||||||
}
|
|
||||||
|
|
||||||
Exec { path => "/usr/sbin:/usr/bin:/sbin:/bin" }
|
|
||||||
|
|
||||||
class {'apt': }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,14 +38,6 @@ class zulip::local_server {
|
||||||
target => '/home/zulip/deployments/current/prod-static/serve',
|
target => '/home/zulip/deployments/current/prod-static/serve',
|
||||||
}
|
}
|
||||||
|
|
||||||
# This is just an empty file. It's used by the app to test if it's running
|
|
||||||
# on a local server.
|
|
||||||
file { '/etc/zulip/local':
|
|
||||||
ensure => file,
|
|
||||||
mode => 644,
|
|
||||||
content => '',
|
|
||||||
}
|
|
||||||
|
|
||||||
file { "/usr/share/postgresql/9.1/tsearch_data/zulip_english.stop":
|
file { "/usr/share/postgresql/9.1/tsearch_data/zulip_english.stop":
|
||||||
require => Package["postgresql-9.1"],
|
require => Package["postgresql-9.1"],
|
||||||
ensure => file,
|
ensure => file,
|
||||||
|
|
|
@ -15,9 +15,7 @@ logging.basicConfig(format="%(asctime)s restart-server: %(message)s",
|
||||||
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
|
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
os.chdir(deploy_path)
|
os.chdir(deploy_path)
|
||||||
|
|
||||||
if os.path.exists("/etc/zulip/server"):
|
if pwd.getpwuid(os.getuid())[0] != "zulip":
|
||||||
with open("/etc/zulip/machinetype") as mtf:
|
|
||||||
if pwd.getpwuid(os.getuid())[0] != "zulip":
|
|
||||||
logging.error("Must be run as user 'zulip'.")
|
logging.error("Must be run as user 'zulip'.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@ cp -a /root/zulip/puppet/zulip/files/puppet.conf /etc/puppet/
|
||||||
ssh $SSH_OPTS "$server" -t -i "$amazon_key_file" -lroot <<EOF
|
ssh $SSH_OPTS "$server" -t -i "$amazon_key_file" -lroot <<EOF
|
||||||
cp -a /root/zulip/puppet/zulip/files/puppet.conf /etc/puppet/
|
cp -a /root/zulip/puppet/zulip/files/puppet.conf /etc/puppet/
|
||||||
|
|
||||||
puppet apply -e 'class {"zulip": machinetype => "local_server"}'
|
mkdir /etc/zulip
|
||||||
|
echo -e "[machine]\npuppet_classes = zulip::local_server" > /etc/zulip/zulip.conf
|
||||||
|
/root/zulip/scripts/zulip-puppet-apply -f
|
||||||
cp -a /root/zulip /home/zulip/zulip
|
cp -a /root/zulip /home/zulip/zulip
|
||||||
chown -R zulip:zulip /home/zulip/zulip
|
chown -R zulip:zulip /home/zulip/zulip
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import ConfigParser
|
||||||
|
import re
|
||||||
|
|
||||||
force = False
|
force = False
|
||||||
extra_args = sys.argv[1:]
|
extra_args = sys.argv[1:]
|
||||||
|
@ -10,10 +12,18 @@ if len(extra_args) and extra_args[0] in ('-f', '--force'):
|
||||||
force = True
|
force = True
|
||||||
eatra_args = extra_args[1:]
|
eatra_args = extra_args[1:]
|
||||||
|
|
||||||
with open('/etc/zulip/machinetype') as f:
|
config = ConfigParser.RawConfigParser()
|
||||||
machinetype = f.readline().strip()
|
config.read("/etc/zulip/zulip.conf")
|
||||||
|
|
||||||
puppet_cmd = ["puppet", "apply", "-e", "class {'zulip-internal': machinetype => '%s'}" % (machinetype,)]
|
puppet_config = """
|
||||||
|
Exec { path => "/usr/sbin:/usr/bin:/sbin:/bin" }
|
||||||
|
class { 'apt': }
|
||||||
|
"""
|
||||||
|
|
||||||
|
for pclass in re.split(r'\s*,\s*', config.get('machine', 'puppet_classes')):
|
||||||
|
puppet_config += "class { '%s': }\n" % (pclass,)
|
||||||
|
|
||||||
|
puppet_cmd = ["puppet", "apply", "-e", puppet_config]
|
||||||
puppet_cmd += extra_args
|
puppet_cmd += extra_args
|
||||||
|
|
||||||
if force:
|
if force:
|
||||||
|
|
|
@ -83,7 +83,9 @@ cp -a /root/zulip/puppet/zulip/files/puppet.conf /etc/puppet/
|
||||||
|
|
||||||
userdel admin
|
userdel admin
|
||||||
passwd -d root
|
passwd -d root
|
||||||
puppet apply -e 'class {"zulip": machinetype => "$type"}'
|
mkdir /etc/zulip
|
||||||
|
echo -e "[machine]\npuppet_classes =" $type > /etc/zulip/zulip.conf
|
||||||
|
/root/zulip/scripts/zulip-puppet-apply -f
|
||||||
cp -a /root/zulip /home/zulip/zulip
|
cp -a /root/zulip /home/zulip/zulip
|
||||||
chown -R zulip:zulip /home/zulip/zulip
|
chown -R zulip:zulip /home/zulip/zulip
|
||||||
# These server restarting bits should be moveable into puppet-land, ideally
|
# These server restarting bits should be moveable into puppet-land, ideally
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
import os
|
||||||
|
import ConfigParser
|
||||||
|
import platform
|
||||||
|
import re
|
||||||
|
|
||||||
|
config = ConfigParser.RawConfigParser()
|
||||||
|
config.add_section("machine")
|
||||||
|
|
||||||
|
with open('/etc/zulip/machinetype') as f:
|
||||||
|
machinetype = f.readline().strip()
|
||||||
|
|
||||||
|
config.set('machine', 'puppet_classes', "zulip-internal::%s" % (machinetype,))
|
||||||
|
|
||||||
|
if os.path.exists('/etc/zulip/server'):
|
||||||
|
if platform.node() == 'staging.zulip.net':
|
||||||
|
deploy_type = 'staging'
|
||||||
|
elif not not re.match(r'^test', platform.node()):
|
||||||
|
deploy_type = 'test'
|
||||||
|
else:
|
||||||
|
deploy_type = 'prod'
|
||||||
|
|
||||||
|
config.set('machine', 'deploy_type', deploy_type)
|
||||||
|
|
||||||
|
config.write(open('/etc/zulip/zulip.conf', 'w'))
|
|
@ -1,7 +1,7 @@
|
||||||
# Secret Django settings for the Zulip project
|
# Secret Django settings for the Zulip project
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import ConfigParser
|
||||||
|
|
||||||
# Make this unique, and don't share it with anybody.
|
# Make this unique, and don't share it with anybody.
|
||||||
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
||||||
|
@ -44,14 +44,17 @@ EMAIL_HOST_USER = 'zulip@zulip.com'
|
||||||
EMAIL_HOST_PASSWORD = 'xxxxxxxxxxxxxxxx'
|
EMAIL_HOST_PASSWORD = 'xxxxxxxxxxxxxxxx'
|
||||||
EMAIL_PORT = 587
|
EMAIL_PORT = 587
|
||||||
|
|
||||||
|
config_file = ConfigParser.RawConfigParser()
|
||||||
|
config_file.read("/etc/zulip/zulip.conf")
|
||||||
|
|
||||||
# Whether we're running in a production environment. Note that DEPLOYED does
|
# Whether we're running in a production environment. Note that DEPLOYED does
|
||||||
# **not** mean hosted by us; customer sites are DEPLOYED and LOCAL_SERVER
|
# **not** mean hosted by us; customer sites are DEPLOYED and LOCAL_SERVER
|
||||||
# and as such should not for example assume they are the main Zulip site.
|
# and as such should not for example assume they are the main Zulip site.
|
||||||
DEPLOYED = os.path.exists('/etc/zulip/server')
|
DEPLOYED = config_file.has_option('machine', 'deploy_type')
|
||||||
STAGING_DEPLOYED = (platform.node() == 'staging.zulip.net')
|
STAGING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'staging'
|
||||||
TESTING_DEPLOYED = not not re.match(r'^test', platform.node())
|
TESTING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'test'
|
||||||
|
|
||||||
LOCAL_SERVER = os.path.exists('/etc/zulip-local')
|
LOCAL_SERVER = DEPLOYED and config_file.get('machine', 'deploy_type') == 'local'
|
||||||
|
|
||||||
if TESTING_DEPLOYED:
|
if TESTING_DEPLOYED:
|
||||||
EXTERNAL_HOST = platform.node()
|
EXTERNAL_HOST = platform.node()
|
||||||
|
|
|
@ -5,19 +5,22 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import time
|
import time
|
||||||
import re
|
|
||||||
import sys
|
import sys
|
||||||
|
import ConfigParser
|
||||||
|
|
||||||
from zerver.openid import openid_failure_handler
|
from zerver.openid import openid_failure_handler
|
||||||
|
|
||||||
|
config_file = ConfigParser.RawConfigParser()
|
||||||
|
config_file.read("/etc/zulip/zulip.conf")
|
||||||
|
|
||||||
# Whether we're running in a production environment. Note that DEPLOYED does
|
# Whether we're running in a production environment. Note that DEPLOYED does
|
||||||
# **not** mean hosted by us; customer sites are DEPLOYED and LOCAL_SERVER
|
# **not** mean hosted by us; customer sites are DEPLOYED and LOCAL_SERVER
|
||||||
# and as such should not for example assume they are the main Zulip site.
|
# and as such should not for example assume they are the main Zulip site.
|
||||||
DEPLOYED = os.path.exists('/etc/zulip/server')
|
DEPLOYED = config_file.has_option('machine', 'deploy_type')
|
||||||
STAGING_DEPLOYED = (platform.node() == 'staging.zulip.net')
|
STAGING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'staging'
|
||||||
TESTING_DEPLOYED = not not re.match(r'^test', platform.node())
|
TESTING_DEPLOYED = DEPLOYED and config_file.get('machine', 'deploy_type') == 'test'
|
||||||
|
|
||||||
LOCAL_SERVER = os.path.exists('/etc/zulip-local')
|
LOCAL_SERVER = DEPLOYED and config_file.get('machine', 'deploy_type') == 'local'
|
||||||
|
|
||||||
# TODO: Clean this up
|
# TODO: Clean this up
|
||||||
if TESTING_DEPLOYED:
|
if TESTING_DEPLOYED:
|
||||||
|
|
Loading…
Reference in New Issue