Generate random traefik api password

This commit is contained in:
GeorgianaElena
2019-02-13 14:10:28 +02:00
parent f7f686f540
commit e8b303d01b
9 changed files with 30 additions and 23 deletions

View File

@@ -120,9 +120,18 @@ def ensure_jupyterhub_service(prefix):
with open(os.path.join(HERE, 'systemd-units', 'jupyterhub.service')) as f:
hub_unit_template = f.read()
# with open(os.path.join(HERE, 'systemd-units', 'configurable-http-proxy.service')) as f:
# chp_unit_template = f.read()
with open(os.path.join(HERE, 'systemd-units', 'traefik.service')) as f:
traefik_unit_template = f.read()
#Set up proxy / hub secret token if it is not already setup
proxy_secret_path = os.path.join(STATE_DIR, 'traefik-api.secret')
if not os.path.exists(proxy_secret_path):
with open(proxy_secret_path, 'w') as f:
f.write(secrets.token_hex(32))
traefik.ensure_traefik_config(STATE_DIR)
unit_params = dict(
@@ -132,13 +141,14 @@ def ensure_jupyterhub_service(prefix):
)
systemd.install_unit('jupyterhub.service', hub_unit_template.format(**unit_params))
systemd.install_unit('traefik.service', traefik_unit_template.format(**unit_params))
# systemd.install_unit('configurable-http-proxy.service', chp_unit_template.format(**unit_params))
systemd.reload_daemon()
# If JupyterHub is running, we want to restart it.
systemd.restart_service('jupyterhub')
systemd.restart_service('traefik')
# Mark JupyterHub & CHP to start at boot time
# Mark JupyterHub & traefik to start at boot time
systemd.enable_service('jupyterhub')
systemd.enable_service('traefik')