-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication-jupyter.yml
136 lines (116 loc) · 3.92 KB
/
application-jupyter.yml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#https://gitlab.com/rsc-surf-nl/rsc-plugins/-/blob/master/ansible/application-jupyter/application-jupyter.yml
- name: Install and configure Jupyter
hosts:
- all
- 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_distribution == 'Ubuntu'
block:
- name: Install required packages
package:
name:
- apt-transport-https
- python3
- python3-setuptools
- python3-pip
- python3-matplotlib
- jq
- curl
- nodejs
- npm
state: present
- name: Ensure python 3 packages for Jupyter are installed
pip:
name: "{{ packages }}"
executable: pip3
extra_args: "-U"
vars:
packages:
- jupyterlab #==3.0.11
- jupyterhub #==1.3.0
- virtualenv #==20.4.3
- jupyterlab-git #==0.30.0b3
- jinja2
- name: Ensure configurable-http-proxy is installed
npm:
global: yes
name: configurable-http-proxy
# version: '4.3.2'
- 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 / {
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 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
copy:
dest: /etc/jupyterhub/jupyterhub_config.py
content: |
c.Spawner.default_url = '/lab?reset'
c.Spawner.notebook_dir = '~'
c.Authenticator.admin_users = {'{{ ssh_user | default('vagrant', true) }}'}
c.Authenticator.delete_invalid_users = True
c.JupyterHub.port = 8000
c.JupyterHub.cleanup_servers = False
c.JupyterHub.cleanup_proxy = False
c.JupyterHub.template_vars = {'announcement_login': 'Welcome to the AMUSE workspace'}
- 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=/usr/local/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
- name: Upgrade nbdime
pip:
name: nbdime
extra_args: --upgrade
- 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)