Commit b30e27f0 by Jocelyn Delalande

jupyter: add role

parent fbd54adb
Jupyter − Installs standalone jupyter server
============================================
Installs a [Jupyter](http://jupyter.org/) notebook server. Note that this **is
not** a *jupyterhub* server (which handles fine auth/authz and security) ; so in terms of multi-user,
this is a bit raw.
Variables
---------
### Optional
- `jupyter_access_token`: the hardcoded password to protect jupyter instance
(if unspecified, random and appearing in the logs).
- name: restart jupyter
service: name=jupyter state=restarted daemon_reload=yes
- name: install apt dependencies
apt: pkg={{ item }}
with_items:
- python3
- python3-dev
- libzmq-dev
- python-virtualenv
- name: create dedicated user
user: name=jupyter home=/opt/jupyter
- name: create notebooks dir
file: path=/opt/jupyter/notebooks state=directory owner=jupyter
- name: install recent pip
pip: name=pip virtualenv_python=python3 virtualenv=/opt/jupyter/venv
become: jupyter
- name: install jupyter
pip: name=jupyter virtualenv=/opt/jupyter/venv
become: jupyter
notify: restart jupyter
- name: systemd script is in place
template:
src: jupyter.service.j2
dest: /etc/systemd/system/jupyter.service
notify: restart jupyter
- name: ensure jupyter is started
service: name=jupyter state=started
- name: install supervisor
apt: pkg=supervisor
notify: restart supervisor
- name: copy jupyter supervisor file
- template:
src: jupyter-supervisor.conf.j2
dest: /etc/supervisor/conf.d/jupyter.conf
notify: restart supervisor
[program:jupyter]
command=/opt/jupyter/bin/jupyter notebook --notebook-dir=/opt/jupyter/notebooks --no-browser --NotebookApp.allow_origin='*'
process_name=worker-jupyter-%(process_num)02d
# TODO amb: take more than `1` here
numprocs=1
startretries=9999
directory=/opt/jupyter
autostart=true
autorestart=true
user=jupyter
stdout_logfile=/var/log/supervisor_jupyter_stdout.log
stdout_logfile_maxbytes=1MB
stderr_logfile=/var/log/supervisor_jupyter_stderr.log
stderr_logfile_maxbytes=1MB
[Unit]
Description=Jupyter
After=network.target
[Service]
User=jupyter
Group=jupyter
WorkingDirectory=/opt/jupyter/
ExecStart=/opt/jupyter/venv/bin/jupyter notebook --notebook-dir=/opt/jupyter/notebooks --no-browser --NotebookApp.allow_origin='*' "--ip=::1" {% if jupyter_access_token is defined =}--NotebookApp.token={{ jupyter_access_token }}{% endif %}
[Install]
WantedBy=multi-user.target
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment