diff --git a/molecule/playbook-jupyterhub/molecule.yml b/molecule/playbook-jupyterhub/molecule.yml index 200ee946..deaff12e 100644 --- a/molecule/playbook-jupyterhub/molecule.yml +++ b/molecule/playbook-jupyterhub/molecule.yml @@ -21,3 +21,4 @@ provisioner: jupyter_auth: noauth jupyter_activate_remote_user_auth: true # mock SRAM auth by enabling remote user auth in JupyterHub config, despite setting auth to noauth. jupyter_proxy_config: "{ proxy_set_header: { REMOTE_USER: '$$http_user'} }" + jupyterhub_debug: true diff --git a/playbooks/roles/jupyterhub/defaults/main.yml b/playbooks/roles/jupyterhub/defaults/main.yml index 5632bc23..2a9e4e47 100644 --- a/playbooks/roles/jupyterhub/defaults/main.yml +++ b/playbooks/roles/jupyterhub/defaults/main.yml @@ -14,6 +14,7 @@ jupyterhub_http_password: "" jupyterhub_create_default_group: true jupyterhub_remote_user_header: REMOTE_USER jupyterhub_activate_remote_user_auth: false +jupyterhub_enable_unix_socket: true jupyterhub_config_env_keep: - JUPYTERHUB_ACTIVITY_URL - JUPYTERHUB_SERVER_NAME @@ -27,3 +28,4 @@ jupyterhub_config_env_keep: - PATH - CONDA_ROOT - CONDA_DEFAULT_ENV +jupyterhub_debug: false diff --git a/playbooks/roles/jupyterhub/molecule/default/converge.yml b/playbooks/roles/jupyterhub/molecule/default/converge.yml index 76859df2..4be6d0e0 100644 --- a/playbooks/roles/jupyterhub/molecule/default/converge.yml +++ b/playbooks/roles/jupyterhub/molecule/default/converge.yml @@ -8,5 +8,6 @@ jupyterhub_proxy_config: proxy_set_header: REMOTE_USER: '$http_user' # allows us to set the 'user' header in tests to mock login + jupyterhub_debug: true roles: - role: jupyterhub diff --git a/playbooks/roles/jupyterhub/templates/jupyterhub_config.py.j2 b/playbooks/roles/jupyterhub/templates/jupyterhub_config.py.j2 index cc4b79c1..af2522c3 100644 --- a/playbooks/roles/jupyterhub/templates/jupyterhub_config.py.j2 +++ b/playbooks/roles/jupyterhub/templates/jupyterhub_config.py.j2 @@ -38,6 +38,12 @@ c.AccessTokenAuthenticator.header_name = "{{ jupyterhub_remote_user_header }}" c.AccessTokenAuthenticator.logout_endpoint = "/logout" {% endif %} +{% if jupyterhub_debug %} +# Debug settings +c.JupyterHub.log_level = logging.DEBUG +c.ConfigurableHTTPProxy.debug = True +{% endif %} + # Spawner config c.JupyterHub.spawner_class = 'sudospawner.SudoSpawner' @@ -51,10 +57,18 @@ c.Spawner.args = [ c.Spawner.env_keep = {{ jupyterhub_config_env_keep | string }} # Server config - +{% if jupyterhub_enable_unix_socket %} +c.JupyterHub.hub_bind_url = "unix+http://{{ jupyterhub_user_home | replace("/", "%2F") }}%2Fjupyterhub.sock" +c.JupyterHub.hub_connect_url = c.JupyterHub.hub_bind_url +c.Spawner.environment.update({ + 'JUPYTERHUB_API_URL': "http://localhost:8000/hub/api", + 'JUPYTERHUB_ACTIVITY_URL': lambda spawner : f"http://localhost:8000/hub/api/users/{spawner.user.name}/activity" +}) +{% else %} c.JupyterHub.ip = "{{ jupyterhub_bind_addr }}" c.JypyterHub.port = {{ jupyterhub_port | int }} c.JupyterHub.base_url = "{{ jupyterhub_uri }}" +{% endif %} # Configure paths for essential server files c.JupyterHub.cookie_secret_file = "{{ jupyterhub_user_home }}/jupyterhub_cookie_secret"