93 lines
2.3 KiB
YAML
93 lines
2.3 KiB
YAML
---
|
|
# JupyterLab — notebook interface for AI/ML development
|
|
- name: Install JupyterLab in cezen conda env
|
|
become_user: cezen
|
|
shell: |
|
|
/opt/cezen/miniconda/bin/conda run -n cezen pip install \
|
|
jupyterlab \
|
|
ipywidgets \
|
|
ipykernel \
|
|
notebook \
|
|
nbconvert
|
|
retries: 3
|
|
delay: 10
|
|
|
|
- name: Create JupyterLab config directory
|
|
file:
|
|
path: /opt/cezen/.jupyter
|
|
state: directory
|
|
owner: cezen
|
|
group: cezen
|
|
|
|
- name: Generate JupyterLab config
|
|
become_user: cezen
|
|
shell: |
|
|
/opt/cezen/miniconda/envs/cezen/bin/jupyter lab --generate-config
|
|
args:
|
|
creates: /opt/cezen/.jupyter/jupyter_lab_config.py
|
|
|
|
- name: Configure JupyterLab (no browser, allow all IPs, set base dir)
|
|
lineinfile:
|
|
path: /opt/cezen/.jupyter/jupyter_lab_config.py
|
|
line: "{{ item }}"
|
|
create: yes
|
|
owner: cezen
|
|
loop:
|
|
- "c.ServerApp.ip = '0.0.0.0'"
|
|
- "c.ServerApp.port = 8888"
|
|
- "c.ServerApp.open_browser = False"
|
|
- "c.ServerApp.notebook_dir = '/opt/cezen/notebooks'"
|
|
- "c.ServerApp.token = 'cezen2024'"
|
|
- "c.ServerApp.allow_root = False"
|
|
|
|
- name: Create notebooks directory
|
|
file:
|
|
path: /opt/cezen/notebooks
|
|
state: directory
|
|
owner: cezen
|
|
group: cezen
|
|
|
|
- name: Create sample notebook placeholder
|
|
copy:
|
|
dest: /opt/cezen/notebooks/README.md
|
|
content: |
|
|
# Nexus One AI — JupyterLab
|
|
|
|
Default token: `cezen2024`
|
|
|
|
Change this in: `/opt/cezen/.jupyter/jupyter_lab_config.py`
|
|
Then restart: `sudo systemctl restart jupyterlab`
|
|
owner: cezen
|
|
group: cezen
|
|
|
|
- name: Create JupyterLab systemd service
|
|
copy:
|
|
dest: /etc/systemd/system/jupyterlab.service
|
|
content: |
|
|
[Unit]
|
|
Description=JupyterLab Server
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=cezen
|
|
Group=cezen
|
|
WorkingDirectory=/opt/cezen/notebooks
|
|
ExecStart=/opt/cezen/miniconda/envs/cezen/bin/jupyter lab \
|
|
--config=/opt/cezen/.jupyter/jupyter_lab_config.py
|
|
Restart=always
|
|
RestartSec=5
|
|
Environment="PATH=/opt/cezen/miniconda/envs/cezen/bin:/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin"
|
|
Environment="CUDA_HOME=/usr/local/cuda"
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
mode: "0644"
|
|
|
|
- name: Enable and start JupyterLab
|
|
systemd:
|
|
name: jupyterlab
|
|
enabled: yes
|
|
state: started
|
|
daemon_reload: yes
|