mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Merge pull request #482 from georgejhunt/jupyter
Sync from georgejhunt/iiab:jupyter
This commit is contained in:
commit
6b4b68de8b
11 changed files with 1404 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,3 +5,4 @@ deprecated
|
||||||
*.patches
|
*.patches
|
||||||
*.log
|
*.log
|
||||||
*.retry
|
*.retry
|
||||||
|
*~
|
||||||
|
|
2
roles/jupyterhub/defaults/main.yml
Normal file
2
roles/jupyterhub/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
jupyterhub_venv: /opt/iiab/jupyterhub
|
||||||
|
jupyterhub_port: 8000
|
7
roles/jupyterhub/docs/README.md
Normal file
7
roles/jupyterhub/docs/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
### Jupyter Notebooks on Rpi Server
|
||||||
|
* Jupyter Notebooks are widely used in the scientific community.
|
||||||
|
* This IIAB package permits individal users to start using their own notebook on the server without needing an individual server account.
|
||||||
|
* Once a user signs in with a user name, and password, these credentials are stored, and are used thereafter to gain access to the user's files.
|
||||||
|
* Individual folders are created for all student work in the path /var/lib/protected/. Individual students will only be able to see their own work in that directory.
|
||||||
|
* Students will not have any privileges outside of their own folder.
|
||||||
|
* They may upload jupyter notebooks from a local machine, and download the current state of their work via a normal browser download.
|
41
roles/jupyterhub/tasks/enable-or-disable.yml
Normal file
41
roles/jupyterhub/tasks/enable-or-disable.yml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
- name: systemd daemon-reload
|
||||||
|
systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
|
||||||
|
|
||||||
|
# enable or disable
|
||||||
|
- name: Enable & Restart jupyterhub
|
||||||
|
systemd:
|
||||||
|
name: "{{ item }}"
|
||||||
|
enabled: yes
|
||||||
|
state: restarted
|
||||||
|
with_items:
|
||||||
|
- jupyterhub.service
|
||||||
|
when: jupyterhub_enabled
|
||||||
|
|
||||||
|
- name: Disable jupyterhub
|
||||||
|
systemd:
|
||||||
|
name: "{{ item }}"
|
||||||
|
enabled: no
|
||||||
|
state: stopped
|
||||||
|
with_items:
|
||||||
|
- jupyterhub
|
||||||
|
when: not jupyterhub_enabled
|
||||||
|
|
||||||
|
|
||||||
|
- name: Put the nginx config file in place
|
||||||
|
template:
|
||||||
|
src: jupyterhub-nginx.conf
|
||||||
|
dest: "{{ nginx_conf_dir }}/"
|
||||||
|
when: jupyterhub_enabled
|
||||||
|
|
||||||
|
- name: Disable jupyterhub
|
||||||
|
file:
|
||||||
|
path: "{{ nginx_conf_dir }}/jupyterhub-nginx.conf"
|
||||||
|
state: absent
|
||||||
|
when: not jupyterhub_enabled
|
||||||
|
|
||||||
|
- name: Restart 'nginx' systemd service
|
||||||
|
systemd:
|
||||||
|
name: nginx
|
||||||
|
state: restarted
|
55
roles/jupyterhub/tasks/install.yml
Normal file
55
roles/jupyterhub/tasks/install.yml
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
- name: Make the directories to hold jupyter config
|
||||||
|
file:
|
||||||
|
state: directory
|
||||||
|
path: '{{ item }}'
|
||||||
|
with_items:
|
||||||
|
- '{{ jupyterhub_venv }}/etc/jupyter'
|
||||||
|
- '{{ jupyterhub_venv }}/etc/jupyterhub'
|
||||||
|
- '{{ jupyterhub_venv }}/etc/systemd'
|
||||||
|
|
||||||
|
- name: "Set 'nodejs_install: True' and 'nodejs_enabled: True'"
|
||||||
|
set_fact:
|
||||||
|
nodejs_install: True
|
||||||
|
nodejs_enabled: True
|
||||||
|
|
||||||
|
- name: NODEJS - run 'nodejs' role (attempt to install & enable Node.js)
|
||||||
|
include_role:
|
||||||
|
name: nodejs
|
||||||
|
|
||||||
|
- name: FAIL (STOP THE INSTALL) IF 'nodejs_installed is undefined'
|
||||||
|
fail:
|
||||||
|
msg: "Jupyter install cannot proceed, as Node.js is not installed."
|
||||||
|
when: nodejs_installed is undefined
|
||||||
|
|
||||||
|
- name: use npm to install configurable http proxy
|
||||||
|
npm:
|
||||||
|
name: configurable-http-proxy
|
||||||
|
global: yes
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
- name: Use pip to install into a virtual environment
|
||||||
|
pip:
|
||||||
|
name:
|
||||||
|
- pip
|
||||||
|
- wheel
|
||||||
|
- ipywidgets
|
||||||
|
- jupyterhub
|
||||||
|
- jupyterlab
|
||||||
|
- jupyterhub_firstuseauthenticator
|
||||||
|
- jupyterhub-systemdspawner
|
||||||
|
virtualenv: "{{ jupyterhub_venv }}" # /opt/iiab/jupyter
|
||||||
|
virtualenv_site_packages: no
|
||||||
|
virtualenv_command: /usr/bin/virtualenv
|
||||||
|
virtualenv_python: python3
|
||||||
|
extra_args: "--no-cache-dir"
|
||||||
|
when: internet_available
|
||||||
|
|
||||||
|
- name: Install the config file for jupyterhub
|
||||||
|
template:
|
||||||
|
src: jupyterhub_config.py
|
||||||
|
dest: '{{ jupyterhub_venv }}/etc/jupyterhub/'
|
||||||
|
|
||||||
|
- name: Use systemd to start jupyterhub
|
||||||
|
template:
|
||||||
|
src: jupyterhub.service
|
||||||
|
dest: /etc/systemd/system/
|
23
roles/jupyterhub/tasks/main.yml
Normal file
23
roles/jupyterhub/tasks/main.yml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
- name: Install Jupyter if jupyterhub_installed not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
|
||||||
|
include_tasks: install.yml
|
||||||
|
when: jupyterhub_installed is undefined
|
||||||
|
|
||||||
|
|
||||||
|
- include_tasks: enable-or-disable.yml
|
||||||
|
|
||||||
|
|
||||||
|
- name: Add 'jupyter' variable values to {{ iiab_ini_file }}
|
||||||
|
ini_file:
|
||||||
|
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
|
||||||
|
section: jupyter
|
||||||
|
option: "{{ item.option }}"
|
||||||
|
value: "{{ item.value | string }}"
|
||||||
|
with_items:
|
||||||
|
- option: name
|
||||||
|
value: Jupyter
|
||||||
|
- option: description
|
||||||
|
value: '"Raspberry Pi Jupyter python programming environment"'
|
||||||
|
- option: install
|
||||||
|
value: "{{ jupyterhub_install }}"
|
||||||
|
- option: enabled
|
||||||
|
value: "{{ jupyterhub_enabled }}"
|
20
roles/jupyterhub/templates/jupyterhub-nginx.conf
Normal file
20
roles/jupyterhub/templates/jupyterhub-nginx.conf
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
location /jupyterhub {
|
||||||
|
proxy_pass http://127.0.0.1:8000;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-NginX-Proxy true;
|
||||||
|
|
||||||
|
|
||||||
|
# websocket headers
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
#proxy_set_header Connection $connection_upgrade;
|
||||||
|
proxy_set_header X-Scheme $scheme;
|
||||||
|
|
||||||
|
proxy_buffering off;
|
||||||
|
}
|
||||||
|
# Managing requests to verify letsencrypt host
|
||||||
|
location ~ /.well-known {
|
||||||
|
allow all;
|
||||||
|
}
|
11
roles/jupyterhub/templates/jupyterhub.service
Normal file
11
roles/jupyterhub/templates/jupyterhub.service
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=JupyterHub
|
||||||
|
After=syslog.target network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:{{ jupyterhub_venv }}/bin"
|
||||||
|
ExecStart={{ jupyterhub_venv }}/bin/python3 -m jupyterhub -f {{ jupyterhub_venv }}/etc/jupyterhub/jupyterhub_config.py
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
1238
roles/jupyterhub/templates/jupyterhub_config.py
Normal file
1238
roles/jupyterhub/templates/jupyterhub_config.py
Normal file
File diff suppressed because it is too large
Load diff
|
@ -72,6 +72,7 @@ pbx_data_ports={{ pbx_data_ports }}
|
||||||
sugarizer_port={{ sugarizer_port }}
|
sugarizer_port={{ sugarizer_port }}
|
||||||
transmission_http_port={{ transmission_http_port }}
|
transmission_http_port={{ transmission_http_port }}
|
||||||
transmission_peer_port={{ transmission_peer_port }}
|
transmission_peer_port={{ transmission_peer_port }}
|
||||||
|
jupyterhub_port={{ jupyterhub_port }}
|
||||||
|
|
||||||
samba_udp_ports={{ samba_udp_ports }}
|
samba_udp_ports={{ samba_udp_ports }}
|
||||||
samba_tcp_mports={{ samba_tcp_mports }}
|
samba_tcp_mports={{ samba_tcp_mports }}
|
||||||
|
@ -158,7 +159,8 @@ if [ "$wan" != "none" ]; then
|
||||||
|
|
||||||
$IPTABLES -A INPUT -p tcp --dport $sugarizer_port -m state --state NEW -i $wan -j ACCEPT
|
$IPTABLES -A INPUT -p tcp --dport $sugarizer_port -m state --state NEW -i $wan -j ACCEPT
|
||||||
$IPTABLES -A INPUT -p tcp --dport $transmission_http_port -m state --state NEW -i $wan -j ACCEPT
|
$IPTABLES -A INPUT -p tcp --dport $transmission_http_port -m state --state NEW -i $wan -j ACCEPT
|
||||||
$IPTABLES -A INPUT -p tcp --dport $transmission_peer_port -m state --state NEW -i $wan -j ACCEPT
|
$IPTABLES -A INPUT -p tcp --dport $transmission_http_port -m state --state NEW -i $wan -j ACCEPT
|
||||||
|
$IPTABLES -A INPUT -p tcp --dport $jupyterhub_port -m state --state NEW -i $wan -j ACCEPT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 4 = ssh + http-or-https + common IIAB services + Samba
|
# 4 = ssh + http-or-https + common IIAB services + Samba
|
||||||
|
|
|
@ -564,6 +564,9 @@ phpmyadmin_enabled: False
|
||||||
vnstat_install: False
|
vnstat_install: False
|
||||||
vnstat_enabled: False
|
vnstat_enabled: False
|
||||||
|
|
||||||
|
jupyterhub_install: False
|
||||||
|
jupyterhub_enabled: False
|
||||||
|
jupyterhub_port: 8000
|
||||||
|
|
||||||
# 9-LOCAL-ADDONS
|
# 9-LOCAL-ADDONS
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue