From 3124cf1f8087fdfa7f74afd05f5296b3256a5af8 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Mon, 30 Jul 2018 22:35:55 -0700 Subject: [PATCH 1/4] Load arbitrary .py config files from a conf.d dir We want to keep the amount of custom code we support extremely small. This provides a nice escape hatch for everything else. --- tljh/jupyterhub_config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tljh/jupyterhub_config.py b/tljh/jupyterhub_config.py index 1e28469..21976e9 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, 'config.d', '*.py'))) +for ec in extra_configs: + load_subconfig(ec) From edfbbd8ae9cb5a4a0383af5c1c731c367ff58754 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Wed, 1 Aug 2018 02:47:44 -0700 Subject: [PATCH 2/4] Use jupyterhub_config.d rather than config.d for overrides Makes it clearer that these are jupyterhub_config.py snippets rather than config.yaml snippets --- tljh/jupyterhub_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tljh/jupyterhub_config.py b/tljh/jupyterhub_config.py index 21976e9..4abb891 100644 --- a/tljh/jupyterhub_config.py +++ b/tljh/jupyterhub_config.py @@ -50,6 +50,6 @@ 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, 'config.d', '*.py'))) +extra_configs = sorted(glob(os.path.join(INSTALL_PREFIX, 'jupyterhub_config.d', '*.py'))) for ec in extra_configs: load_subconfig(ec) From c5fc1a70d7c140b0017caa07fa21168378d6ab7b Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Wed, 1 Aug 2018 02:52:40 -0700 Subject: [PATCH 3/4] Add docs for escape hatch --- docs/index.rst | 1 + docs/topic/escape-hatch.rst | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 docs/topic/escape-hatch.rst 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..bb42bc5 --- /dev/null +++ b/docs/topic/escape-hatch.rst @@ -0,0 +1,16 @@ +.. _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. + +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 by TLJH are loaded. \ No newline at end of file From 0da615ce5a9336b10f20d7d7ad25df4eb871a61f Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Thu, 2 Aug 2018 10:57:26 -0700 Subject: [PATCH 4/4] Add note about creating jupyterhub_config.d directory --- docs/topic/escape-hatch.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/topic/escape-hatch.rst b/docs/topic/escape-hatch.rst index bb42bc5..5ed82b1 100644 --- a/docs/topic/escape-hatch.rst +++ b/docs/topic/escape-hatch.rst @@ -7,10 +7,11 @@ 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. +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 by TLJH are loaded. \ No newline at end of file +options specified with ``tljh-config`` are loaded. \ No newline at end of file