mirror of https://github.com/zulip/zulip.git
droplets: Set the hostname correctly using cloud-init.
This commit is contained in:
parent
0e835c6381
commit
6079c19304
|
@ -106,6 +106,11 @@ def set_user_data(username: str, userkeys: List[Dict[str, Any]]) -> str:
|
|||
ssh_authorized_keys += "\n - {}".format(key['key'])
|
||||
# print(ssh_authorized_keys)
|
||||
|
||||
# We pass the hostname as username.zulipdev.org to the DigitalOcean API.
|
||||
# But some droplets (eg on 18.04) are created with with hostname set to just username.
|
||||
# So we fix the hostname using cloud-init.
|
||||
hostname_setup = "hostnamectl set-hostname {username}.zulipdev.org".format(username=username)
|
||||
|
||||
setup_repo = """\
|
||||
cd /home/zulipdev/{1} && git remote add origin https://github.com/{0}/{1}.git && git fetch origin"""
|
||||
|
||||
|
@ -116,18 +121,20 @@ cd /home/zulipdev/{1} && git remote add origin https://github.com/{0}/{1}.git &&
|
|||
#cloud-config
|
||||
users:
|
||||
- name: zulipdev
|
||||
ssh_authorized_keys:{}
|
||||
ssh_authorized_keys:{ssh_authorized_keys}
|
||||
runcmd:
|
||||
- su -c '{}' zulipdev
|
||||
- {hostname_setup}
|
||||
- su -c '{server_repo_setup}' zulipdev
|
||||
- su -c 'git clean -f' zulipdev
|
||||
- su -c '{}' zulipdev
|
||||
- su -c '{python_api_repo_setup}' zulipdev
|
||||
- su -c 'git clean -f' zulipdev
|
||||
- su -c 'git config --global core.editor nano' zulipdev
|
||||
- su -c 'git config --global pull.rebase true' zulipdev
|
||||
power_state:
|
||||
mode: reboot
|
||||
condition: True
|
||||
""".format(ssh_authorized_keys, server_repo_setup, python_api_repo_setup)
|
||||
""".format(ssh_authorized_keys=ssh_authorized_keys, hostname_setup=hostname_setup,
|
||||
server_repo_setup=server_repo_setup, python_api_repo_setup=python_api_repo_setup)
|
||||
|
||||
print("...returning cloud-config data.")
|
||||
return cloudconf
|
||||
|
|
|
@ -21,12 +21,8 @@ FORWARD_ADDRESS_CONFIG_FILE = "var/forward_address.ini"
|
|||
external_host_env = os.getenv('EXTERNAL_HOST')
|
||||
if external_host_env is None:
|
||||
if IS_DEV_DROPLET:
|
||||
# For most of our droplets, we use the hostname (eg github_username.zulipdev.org) by default.
|
||||
hostname = os.uname()[1].lower()
|
||||
# Some of the droplets (eg droplets on 18.04) has the github_username as hostname.
|
||||
if '.zulipdev.org' not in hostname:
|
||||
hostname += '.zulipdev.org'
|
||||
EXTERNAL_HOST = hostname + ":9991"
|
||||
# For our droplets, we use the hostname (eg github_username.zulipdev.org) by default.
|
||||
EXTERNAL_HOST = os.uname()[1].lower() + ":9991"
|
||||
else:
|
||||
# For local development environments, we use localhost by
|
||||
# default, via the "zulipdev.com" hostname.
|
||||
|
|
Loading…
Reference in New Issue