- Foreword
- Prerequisites
- Setup
- Step 1: Setup Hetzner Cloud instance
- Step 2: Create a new configuration file.
- Step 3: Setup
- Step 4: Create your Hetzner Cloud instance
- Step 4: Add IP Adresses to DNS records of your domain
- Step 5: Deploy the docker containers using Ansible
- Step 6: extract passwords and domain names
- Step 7: Use jupyter notebooks
- Step 8: (later) destroy server
This repository holds terraform and Ansible configuration files to set up Jupyter notebooks on a Hetzner Cloud instance. It uses traefik as a reverse proxy and docker with docker-compose to orchestrate the containers which will run the jupyter notebooks.
Warning
A word of warning: You should be familiar with using the command line. The steps described here try to help you through the process but we can not cover everything.
- Computer running macOS, Linux or Windows with WSL
- A ssh key (create on using
ssh-keygen -t ed25519
) in~/.ssh/id_ed25519
- A Domain name like
alpacabook.de
with access to its DNS entries. - A Hetzner Cloud account.
- Python
- terraform
- Ansible
- Create a new project on the Hetzner Cloud Console
- Create a new token for the project with read/write access (open left sidebar > Security > API-Tokens > add API-Token)
- Copy this token into your password manager of choice as it will only be displayed once.
- Copy the template config to a new file
cp config.tmpl.yaml config.yaml
- Replace the placeholder for
hcloud_token
with your token from Hetzner Cloud. - Replace the placeholder for
domain
with your domain name likealpacabook.de
. - Choose a hostname. This will be the subdomain your server will be reachable by. This could just be
jupyter
for example. So the server will be reachable usingjupyter.alpacabook.de
and the jupyter notebooks will be reachable under00[1,2,3...].jupyter.alpacabook.de
- Add the location of your public key into
ssh_key_location
like~/.ssh/id_ed25519
. This will be the key used to access the server initially. - Add an email for the
email
field under which you will get your certificates from Letsencrypt - Fill the
admins
array. These will be the accounts that will be created on the server. Use your the public part of your ssh-key from above or any other ssh-key from your friends who want to access this server. Regarding the shell: if you know, you know otherwise just leave it as is.
-
install requirements
make install
-
run
generate.py
with number of instances you needpython generate.py -n 10
-
run terraform
make tf_init && make tf_plan
Verify that the settings shown in this plan is what you are expecting.
-
apply terraform
make tf_apply
this will print the public IPv4 and IPv6 addresses
- navigate to your registrar find your chosen domain's DNS records
- add
A
andAAAA
records for*.hostname
andhostname
- the
A
records take the IPv4 address - the
AAAA
records take the IPv6 address - verify that the records are published using
nslookup
ordig
-
Run Ansible
make a_run
This might take a while.
-
in case any step fails, use tags in
ansible/playbook.yaml
to run single steps -
to debug you can access the server via
ssh -i ~/.ssh/private_ssh_key <admin_user>@<hostname>.<domain>
- go to
ansible/config.yaml
- get urls and passwords
The jupyter notebooks can be reached under 001.<hostname>.<domain>
where 001
indicates the instance number.
- open your Hetzner Cloud Console
- deactivate protection
- delete server