diff --git a/docs/index.rst b/docs/index.rst index 5c54c13..0dbe514 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -83,6 +83,7 @@ Topic guides provide in-depth explanations of specific topics. topic/installer-actions topic/tljh-config topic/authenticator-configuration + topic/escape-hatch Troubleshooting diff --git a/docs/topic/escape-hatch.rst b/docs/topic/escape-hatch.rst new file mode 100644 index 0000000..5ed82b1 --- /dev/null +++ b/docs/topic/escape-hatch.rst @@ -0,0 +1,17 @@ +.. _topic/escape-hatch: + +======================================== +Custom ``jupyterhub_config.py`` snippets +======================================== + +Sometimes you need to customize TLJH in ways that are not officially supported. +We provide an easy escape hatch for those cases with a ``jupyterhub_conf.d`` +directory that lets you load multiple ``jupyterhub_config.py`` snippets for +your configuration. You need to create the directory when you use it for +the first time. + +Any files in ``/opt/tljh/jupyterhub_config.d`` that end in ``.py`` will be +loaded in alphabetical order as python files to provide configuration for +JupyterHub. Any config that can go in a regular ``jupyterhub_config.py`` +file is valid in these files. They will be loaded *after* any of the config +options specified with ``tljh-config`` are loaded. \ No newline at end of file diff --git a/tljh/jupyterhub_config.py b/tljh/jupyterhub_config.py index 1e28469..4abb891 100644 --- a/tljh/jupyterhub_config.py +++ b/tljh/jupyterhub_config.py @@ -3,8 +3,8 @@ JupyterHub config for the littlest jupyterhub. """ import copy import os - import yaml +from glob import glob from systemdspawner import SystemdSpawner from tljh import user, configurer @@ -47,3 +47,9 @@ if os.path.exists(config_overrides_path): else: config_overrides = {} configurer.apply_config(config_overrides, c) + +# Load arbitrary .py config files if they exist. +# This is our escape hatch +extra_configs = sorted(glob(os.path.join(INSTALL_PREFIX, 'jupyterhub_config.d', '*.py'))) +for ec in extra_configs: + load_subconfig(ec)