Commit fdd29ae8 authored by Jocelyn Delalande's avatar Jocelyn Delalande

jupyterhub: Bring the role to a working state

parent 36017fff
WIP JupyterHUB role
===================
JupyterHub deployment to learn programming with JS
==================================================
**Work in progress, cannot be used as-is.**
- Deploy JupyterHub
- Deploy IJavasScript kernel to allow JS notebooks
- Tweak IJavaScript config to add `prompt()` and `alert()` synchronous
functions
- Set up a locale (translation)
*see also: jupyter*
## Security warning
Be conscious that JupyterHub gives a remote (unprivilleged) shell access to
logged-in users, and that this implementation is not using docker isolation.
## Performance warning
JupyterHub can be quite intensive on resources, by experience, a group of 10
people toying with a few notebooks will quickly require 2G RAM dedicated to
Jupyter. If you experience killed notebooks or notebooks refusing to start as
more users connect, you should give a look at RAM usage and consider adding
more.
Variables
---------
### Optional (interface language)
Use both or use none, note that you have to use one of
jupyter
[supported languages](https://github.com/JocelynDelalande/notebook/blob/jd-french-i18n/notebook/i18n/nbjs.json#L3-L6). Left
those settings unchanged to use plain old English.
- *jupyterhub_locale* : a unix locale (ex: `fr_FR`)
- *jupyterhub_system_locale* : a unix locale with charset indication (ex: `fr_FR.utf8`)
......@@ -3,5 +3,18 @@
# Not that it seems not required for Debian stretch
- name: Install npm deps
npm:
name: ijavascript
name: "{{ item }}"
global: yes
with_items:
- ijavascript
- fibers # for synchronous functions
- name: Install ijavascript kernel for notebooks
shell: "ijsinstall --install=global --startup-script=/opt/jupyterhub/js-startup.js"
environment:
PATH: "/opt/jupyterhub/venv/bin:{{ ansible_env.PATH }}"
- name: Deploy custom startup script (with custom sync functions for learning)
template:
src: js-startup.js
dest: /opt/jupyterhub/js-startup.js
\ No newline at end of file
# This first task is actually required by ijavascript
# to get a recent version of node (jessie-backports contains one, but with no
# npm…)
# Seems un-needed on strecth (but not tested)
- name: Install node from nodesource as ijs wont run with node 0.10x
# This first task is actually required by ijavascript to get a recent version
# of node (jessie-backports and stretch contains a recent one, but lacking npm)
#
- name: Install node from nodesource
import_tasks: nodesource.yml
- name: install apt dependencies
......@@ -35,6 +34,9 @@
become: jupyterhub
notify: restart jupyterhub
- name: install jupyter notebook (with french translation)
include: notebook.yml
- name: Install npm deps
npm:
name: configurable-http-proxy
......@@ -78,6 +80,9 @@
dest: /etc/jupyterhub/jupyterhub_config.py
notify: restart jupyterhub
- name: Install ijavascript notebook kernel
import_tasks: ijavascript.yml
- name: systemd script is in place
template:
src: jupyterhub.service.j2
......@@ -89,5 +94,3 @@
- name: jupyterhub is started
service: name=jupyterhub state=started
- name: Install ijavascript notebook kernel
import_tasks: ijavascript.yml
- name: Install jupyter notebook
pip:
# Could switch to stable release once PR is merged
# https://github.com/jupyter/notebook/pull/3888
name: "git+https://github.com/JocelynDelalande/notebook.git@jd-french-i18n#egg=notebook"
virtualenv: /opt/jupyterhub/venv
become: jupyterhub
notify: restart jupyterhub
register: updated_notebook
- name: Install pybabel
# Could drop this step once issue is fixed
# https://github.com/jupyter/notebook/issues/3102
pip:
name: babel
virtualenv: /opt/jupyterhub/venv
become: jupyterhub
when: jupyterhub_locale
- name: Install po2json