2021-03-09 22:57:39 +00:00
- 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 :
2021-04-15 19:21:35 +00:00
msg : "JupyterHub install cannot proceed, as Node.js is not installed."
2021-03-09 22:57:39 +00:00
when : nodejs_installed is undefined
2021-04-15 19:21:35 +00:00
2023-06-10 13:10:47 +00:00
- name : Record (initial) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df1
2023-04-26 11:43:28 +00:00
- name : "Install package: python3-psutil"
2021-08-02 08:25:12 +00:00
package :
2023-04-26 11:43:28 +00:00
name : python3-psutil
2021-08-02 08:25:12 +00:00
state : present
2023-04-26 11:43:28 +00:00
- name : Remove previous virtual environment {{ jupyterhub_venv }}
file :
path : "{{ jupyterhub_venv }}"
state : absent
2021-07-27 17:50:35 +00:00
- name : Make 3 directories to hold JupyterHub config
2021-04-15 19:21:35 +00:00
file :
state : directory
2021-04-17 11:43:04 +00:00
path : "{{ item }}"
2021-04-15 19:21:35 +00:00
with_items :
2021-07-27 17:50:35 +00:00
- "{{ jupyterhub_venv }}/etc/jupyter" # /opt/iiab/jupyterhub
2021-04-17 11:43:04 +00:00
- "{{ jupyterhub_venv }}/etc/jupyterhub"
- "{{ jupyterhub_venv }}/etc/systemd"
2021-04-15 19:21:35 +00:00
2021-07-27 17:50:35 +00:00
- name : Use npm to install 'configurable-http-proxy'
2021-03-09 22:57:39 +00:00
npm :
2021-04-15 19:21:35 +00:00
name : configurable-http-proxy
global : yes
state : latest
2021-03-08 01:57:10 +00:00
2023-02-08 17:47:39 +00:00
- name : "pip install 3 packages into virtual environment: {{ jupyterhub_venv }} (~326 MB total, after 2 Ansible calls)"
2021-03-08 01:57:10 +00:00
pip :
name :
2021-04-15 19:21:35 +00:00
- pip
- wheel
- jupyterhub
2021-04-19 17:19:59 +00:00
virtualenv : "{{ jupyterhub_venv }}" # /opt/iiab/jupyterhub
2021-03-08 01:57:10 +00:00
virtualenv_site_packages : no
2023-04-26 11:43:28 +00:00
virtualenv_command : python3 -m venv --system-site-packages "{{ jupyterhub_venv }}" # 2021-07-29: This works on RasPiOS 10, Debian 11, Ubuntu 20.04 and Mint 20 -- however if you absolutely must use the older Debian 10 -- you can work around errors "can't find Rust compiler" and "This package requires Rust >=1.41.0" if you (1) revert this line to 'virtualenv_command: virtualenv' AND (2) uncomment the line just below
2021-07-29 13:28:43 +00:00
#virtualenv_python: python3 # 2021-07-29: Was needed when above line was 'virtualenv_command: virtualenv' (generally for Python 2)
2022-07-08 02:19:15 +00:00
extra_args : "--no-cache-dir" # 2021-11-30, 2022-07-07: The "--pre" flag had earlier been needed, for beta-like pre-releases of JupyterHub 2.0.0
2021-04-15 19:21:35 +00:00
2022-07-07 23:34:30 +00:00
# 2022-07-07: Attempting to "pip install" all 7 together (3 above + 4 below)
# fails on OS's like 64-bit RasPiOS (but interestingly works on Ubuntu 22.04!)
# https://github.com/iiab/iiab/issues/3283
2022-07-08 03:47:32 +00:00
- name : Break up jupyterhub/jupyterlab pip installs into 2 parts (3 packages above + 4 packages here) due to mutual dependency deadlock on some OS's
2022-07-07 22:51:29 +00:00
pip :
name :
2022-07-07 23:17:40 +00:00
- jupyterlab
- jupyterhub_firstuseauthenticator
- jupyterhub-systemdspawner
- ipywidgets
virtualenv : "{{ jupyterhub_venv }}"
2022-07-07 22:51:29 +00:00
virtualenv_site_packages : no
2023-04-26 11:43:28 +00:00
virtualenv_command : python3 -m venv --system-site-packages "{{ jupyterhub_venv }}"
2022-07-08 02:19:15 +00:00
extra_args : "--no-cache-dir"
2022-07-07 22:51:29 +00:00
2021-04-17 11:43:04 +00:00
- name : "Install from template: {{ jupyterhub_venv }}/etc/jupyterhub/jupyterhub_config.py"
2021-03-09 22:57:39 +00:00
template :
2021-09-01 05:13:55 +00:00
src : jupyterhub_config.py.j2
dest : "{{ jupyterhub_venv }}/etc/jupyterhub/jupyterhub_config.py"
2021-03-10 05:15:15 +00:00
2021-04-17 11:43:04 +00:00
- name : "Install from template: /etc/systemd/system/jupyterhub.service"
2021-03-09 04:57:33 +00:00
template :
2021-09-01 05:13:55 +00:00
src : jupyterhub.service.j2
dest : /etc/systemd/system/jupyterhub.service
2021-04-15 19:21:35 +00:00
2022-07-08 03:16:58 +00:00
# 2022-07-07: No longer needed, thx to upstream fixes
2022-12-22 00:29:04 +00:00
# - name: Install {{ jupyterhub_venv }}/bin/getsite.py from template, to fetch site_packages path, e.g. {{ jupyterhub_venv }}/lib/python{{ python_version }}/site-packages
2022-07-08 03:16:58 +00:00
# template:
# src: getsite.py.j2
# dest: "{{ jupyterhub_venv }}/bin/getsite.py"
# mode: 0755
#
# - name: Install patch_FUA.sh from template -- to (1) fix async password-changing page, and (2) force usernames to lowercase -- patching $SITE_PACKAGES/firstuseauthenticator/firstuseauthenticator.py
# template:
# src: patch_FUA.sh.j2
# dest: "{{ jupyterhub_venv }}/bin/patch_FUA.sh"
# mode: 0755
#
# - name: "Run the above two, via: {{ jupyterhub_venv }}/bin/patch_FUA.sh"
# command: "{{ jupyterhub_venv }}/bin/patch_FUA.sh"
2021-09-01 05:13:55 +00:00
2021-09-03 23:13:48 +00:00
- name : Install patch_http-warning.sh from template, to turn off the warning about http insecurity, in {{ jupyterhub_venv }}/share/jupyterhub/templates/login.html
2021-08-31 20:40:42 +00:00
template :
2021-09-01 05:13:55 +00:00
src : patch-http-warning.sh.j2
dest : "{{ jupyterhub_venv }}/bin/patch_http-warning.sh"
mode : 0755
- name : "Now run it: {{ jupyterhub_venv }}/bin/patch_http-warning.sh"
command : "{{ jupyterhub_venv }}/bin/patch_http-warning.sh"
2021-08-31 20:40:42 +00:00
2021-04-15 19:21:35 +00:00
# RECORD JupyterHub AS INSTALLED
2023-06-10 13:10:47 +00:00
- name : Record (final) disk space used
shell : df -B1 --output=used / | tail -1
2023-05-27 07:26:04 +00:00
register : df2
2023-06-10 13:10:47 +00:00
- name : Add 'jupyterhub_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
2023-05-27 07:26:04 +00:00
ini_file :
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section : jupyterhub
option : jupyterhub_disk_usage
2023-06-10 13:10:47 +00:00
value : "{{ df2.stdout|int - df1.stdout|int }}"
2023-05-27 07:26:04 +00:00
2021-04-15 19:21:35 +00:00
- name : "Set 'jupyterhub_installed: True'"
set_fact :
jupyterhub_installed : True
- name : "Add 'jupyterhub_installed: True' to {{ iiab_state_file }}"
lineinfile :
path : "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp : '^jupyterhub_installed'
line: 'jupyterhub_installed : True '