Motivation: why configure local firewalls and NAT tables to host a quick game if you can just spin up a dedicated server at the push of a button?
Terraform configuration to deploy an OpenTTD game server on UpCloud. The server will be running Debian 10, with openttd 1.10.1 compiled from source.
- UpCloud account
- Register at https://upcloud.com/signup/
- Terraform
- Can be installed eg. using Homebrew on Mac OS:
brew install terraform
- Can be installed eg. using Homebrew on Mac OS:
- terraform-provider-upcloud
- Mac OS installation goes something like this:
brew install go
go get github.com/UpCloudLtd/terraform-provider-upcloud
go install github.com/UpCloudLtd/terraform-provider-upcloud
mkdir -p ~/.terraform.d/plugins/
ln -s ~/go/bin/terraform-provider-upcloud ~/.terraform.d/plugins/
- SSH key without a passphrase
- If you don't have one at hand, try something like
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_upcloud
on a *NIX system. Leave passphrase empty so Terraform knows how to use it.
- If you don't have one at hand, try something like
To play on a dedicated openttd server, clone the repo and:
- Modify openttd.cfg with your preferred game settings. Custom NewGRF downloads need to be added to download-newgrf.sh.
- Run
terraform init
in the repo root directory to prepare Terraform. - Run
terraform apply
. You're first prompted for missing config variables and then you'll get a preview of the cloud resources about to be created. Accept the execution plan by typingyes
. - Wait a few minutes while Terraform creates and configures the server.
- Copy the server IP that Terraform prints on exit (
openttd_server_ip
in module outputs) - Connect OpenTTD clients by entering this IP in Main menu → Multiplayer → Add server.
UpCloud will bill your credit card monthly until you delete the server with terraform destroy
.
Many server administration tasks can be done using rcon in OpenTTD in-game console. To enable it, you have to set a rcon_password
in openttd.cfg.
For example, to initialize server with a saved game:
- Transfer
filename.sav
to/home/openttd/.openttd/
(eg. using SFTP) - Connect a client to the server and open the in-game console
- Type
rcon <your-password-here> "load filename"
You can ssh to the server as root with the SSH key you set during provisioning. Common tasks:
- Browse openttd logs with journalctl, eg.
journalctl -o short-iso -n 500 --no-hostname --utc -u openttd
- To edit configuration live:
- Stop openttd – otherwise it will overwrite config on exit:
systemctl stop openttd
- Make desired changes to
/home/openttd/.openttd/openttd.cfg
- Start openttd
systemctl start openttd
- Stop openttd – otherwise it will overwrite config on exit:
Variable | Description |
---|---|
ssh_public_key_path |
Path to a SSH public key that you want to use for managing the server |
ssh_private_key_path |
Path to a SSH private key that you want to use for managing the server |
upcloud_zone |
UpCloud zone to use – default is Helsinki, Finland |
hostname |
Server hostname |