This is a simple manifest to help deploy multiple VPS on Hetzner and provision HORNET automatically.
- Hetzner Account
- Generate an API key via the access menu tab (key icon)
- Make sure you have added your public SSH key in Hetzner's GUI
- Install terraform 0.12 from here
Depending on your OS, choose the right version on terraform's download page
Here's an example installing terraform 0.12.26
on Linux:
$ cd /tmp
$ wget https://releases.hashicorp.com/terraform/0.12.26/terraform_0.12.26_linux_amd64.zip
$ unzip terraform_0.12.26_linux_amd64.zip
$ sudo install -m 755 terraform /usr/local/bin/terraform
$ terraform version
Terraform v0.12.26
git clone https://github.com/nuriel77/hornet-terraform.git && cd hornet-terraform
Export your Hetzner API key via:
export TF_VAR_hcloud_token="your_token_here"
Clone this repository and run:
terrafom init
Configure some variables in variables.tf
, most importantly the name of the SSH key vps_ssh_key
and optionally the vps_type
.
Variables can be configured via environment variables. For example, to set the number of VPSs to deploy:
export TF_VAR_vps_count=3
This will override the default value in variables.tf
.
A simple provisioning script is provided provision.sh
. You can modify it to fit your needs.
This script will be automatically executed on the VPSs once they start up.
Terraform will attempt to SSH into the VPSs using the SSH key loaded into your ssh-agent. Make sure it is available in your ssh-agent (ssh-add -L
)
Simply run:
terraform apply
Just set a new number of desired VPS:
export TF_VAR_vps_count=10
And run terraform apply
to submit. New instances will be added or removed to match the new number.
Run:
terraform destroy