-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtljh.yml
More file actions
106 lines (87 loc) · 3.15 KB
/
tljh.yml
File metadata and controls
106 lines (87 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
- hosts: all
become: true
vars_files:
- vars/default.yml
tasks:
- name: Install required system packages
apt: name={{ item }} state=latest update_cache=yes
loop: [ 'curl', 'python3', 'python3-dev', 'python3-pip']
- name: Download the TLJH installer
get_url:
url: "{{ tljh_installer_url }}"
dest: "{{ tljh_installer_dest }}"
- name: Check if the tljh-plasma is already installed
command: "{{ tljh_prefix }}/hub/bin/python3 -c 'import tljh_plasma'"
register: tljh_plasma_installed
failed_when: tljh_plasma_installed.rc > 2
changed_when: False
- name: Upgrade the tljh-plasma plugins first if it is already installed
shell: "{{ tljh_prefix }}/hub/bin/pip3 install --upgrade {{ tljh_plasma }} {{ tljh_repo2docker }}"
when: tljh_plasma_installed.rc == 0
- name: Run the TLJH installer
shell: |
{{ ansible_python_interpreter }} {{ tljh_installer_dest }} \
--version {{ tljh_version }} \
--plugin {{ tljh_plasma }} {{ tljh_repo2docker }}
# Wait for initial setup to complete
- name: Wait for JupyterHub to be ready after installation
wait_for:
port: 80
delay: 10
timeout: 300
- name: Set the idle culler timeout to 1 hour
shell: "tljh-config set services.cull.timeout 3600"
- name: Set the default memory and cpu limits
shell: |
tljh-config set limits.memory 2G
tljh-config set limits.cpu 2
# Validate configuration before reloading
- name: Validate TLJH configuration
shell: "tljh-config show"
register: config_validation
- name: Stop JupyterHub service gracefully before reload
shell: "systemctl stop jupyterhub.service"
ignore_errors: yes
# Wait a moment for the service to stop
- name: Wait for service to stop
wait_for:
port: 80
state: stopped
timeout: 30
ignore_errors: yes
- name: Check for any remaining JupyterHub processes
shell: "pkill -f jupyterhub || true"
ignore_errors: yes
- name: Start JupyterHub service
shell: "systemctl start jupyterhub.service"
register: start_result
ignore_errors: yes
- name: Wait for JupyterHub to start
wait_for:
port: 80
delay: 5
timeout: 60
when: start_result.rc == 0
- name: Check JupyterHub service status
shell: "systemctl status jupyterhub.service"
register: final_status
ignore_errors: yes
- name: Show JupyterHub logs if service failed
shell: "journalctl -xeu jupyterhub.service --no-pager -n 100"
register: service_logs
when: start_result.rc != 0
- name: Display service logs if startup failed
debug:
msg: "{{ service_logs.stdout }}"
when: start_result.rc != 0
- name: Fail if JupyterHub couldn't start
fail:
msg: "JupyterHub service failed to start. Check the logs above."
when: start_result.rc != 0
# Pull the repo2docker image to build user images
- name: Pull the repo2docker Docker image
docker_image:
name: quay.io/jupyterhub/repo2docker
tag: main
source: pull