src-filesender/application-filesender.yml

159 lines
4.5 KiB
YAML
Raw Normal View History

- name: Install and configure Jupyter
hosts:
- localhost
gather_facts: false
tasks:
- name: Wait for system to become reachable
wait_for_connection:
timeout: 300
- name: Gather facts for first time
setup:
- name: Ubuntu
when: ansible_facts['os_family'] != 'Debian'
fail:
msg: The Jupyter Notebook component is only implemented for distros of the Debian family
- name: Install required packages
apt:
name:
- apt-transport-https
- python3
- python3-setuptools
- python3-pip
- jq
- curl
- ca-certificates
- gnupg
state: present
update_cache: yes
- name: Create keyrings dir
file:
path: /etc/apt/keyrings
state: directory
- name: Install gpg key
shell: >
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key
| sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
- name: deb install
shell: >
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main"
| sudo tee /etc/apt/sources.list.d/nodesource.list
- name: Install NodeJS
apt:
name: nodejs
allow_unauthenticated: yes
update_cache: yes
- name: Ensure python 3 packages for Jupyter are installed
pip:
name: "{{ packages }}"
virtualenv: /etc/src/venv/src-venv
vars:
packages:
- jupyterhub==5.4.2
- jupyterlab==4.4.10
- virtualenv==20.24.2
- jupyterlab-git==0.51.2
- jhub-remote-user-authenticator==0.1.0
- traitlets==5.9.0
- jupyterhub-singleuser-profiles==0.7.0
- name: Ensure python 3 packages for Jupyter are installed
when: "{{ jupyter_simultaneous_edit }}"
pip:
name: jupyter-collaboration
virtualenv: /etc/src/venv/src-venv
- name: Ensure configurable-http-proxy is installed
npm:
global: yes
name: configurable-http-proxy
version: '4.5.5'
- name: Ensure Jupyter configuration directory exists
file:
path: /etc/jupyterhub/
state: directory
- name: Ensure systemd directory exists
file:
path: /usr/lib/systemd/system
state: directory
- name: Create nginx location block
copy:
dest: /etc/nginx/app-location-conf.d/jupyterhub.conf
mode: 0644
content: |
location {{ jupyter_nginx_location|default('/') }} {
error_page 401 = @custom_401;
auth_request /validate;
auth_request_set $username $upstream_http_username;
proxy_set_header REMOTE_USER $username;
proxy_pass http://127.0.0.1:8000;
proxy_redirect http://localhost:8000/ $scheme://$host/;
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-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
client_max_body_size 10G;
}
- name: Restart nginx
service:
name: nginx
state: restarted
- name: Ensure jupyter configuration is in place
template:
src: files/jupyterhub_config.py
dest: /etc/jupyterhub/jupyterhub_config.py
- name: Ensure jupyter systemd config is in place
copy:
dest: /usr/lib/systemd/system/jupyterhub.service
content: |
[Unit]
Description=Jypyter Hub daemon
After=network.target
[Service]
Type=simple
ExecStart=/etc/src/venv/src-venv/bin/jupyterhub --config=/etc/jupyterhub/jupyterhub_config.py
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
- name: Upgrade nbdime
pip:
name: nbdime
extra_args: --upgrade
virtualenv: /etc/src/venv/src-venv
- name: Reload jupyterhub service
systemd:
state: restarted
daemon_reload: yes
name: jupyterhub
- name: Ensure Jupyterhub is started
register: start_jupyterhub
service:
name: jupyterhub
state: restarted
enabled: yes
- debug:
msg: 'service_url: {"url": "https://{{ ansible_host }}", "tag": "web", "description": "Jupyter"}'
when: (start_jupyterhub is succeeded)