Did you ever want to host your personal Cube2 Sauerbraten game server but didn't want to take care of all the necessary steps to set it up?
Welcome to the Cube2 Sauerbraten Game Server Automation project! This open-source solution automates the process of setting up and deploying a Cube2 Sauerbraten game server on the Hetzner Cloud using Terraform, Ansible, and Docker Compose.
With this project, you can quickly and easily create your own Cube2 Sauerbraten game server in the cloud and start playing with friends or the wider gaming community. No more hassle of manual setup and configuration.
It deploys a CX11 Cloud Server, creates a firewall with specified rules, sets up SSH keys for secure access, and triggers Ansible to perform server setup.
Special thanks goes to:
- zanderwork.com
- GitHub captainGeech42/cube2srv
- Docker Hub captaingeech/cube2srv
- Some of the worst documented projects with a decent size, Cube2 Sauberbraten.
- Terraform scripts for provisioning the required cloud infrastructure using Terraform Hetzner Cloud Provider.
- CX11 Cloud Server with 1 vCPU and 2 GB of RAM, this affordable CX11 instance type offers a powerful setup that guarantees a great game experience.
- Ansible playbooks for server setup and management.
- Docker Compose for containerization of the game server.
Before getting started with this project, ensure you have the following installed:
- Terraform (tested with v1.5.0)
- Ansible (tested with v2.11.2)
- Registered Acoount at Hetzner Cloud and a Payment Method
- Clone this repository to your local machine.
- Install the necessary Terraform provider plugins by running
terraform init
. - Create a copy of the terraform.tmpl.tfvars file and save it as
terraform.tfvars
before modifying the following variables to match your requirements:- simply follow this tutorial to generate your personal token
hcloud_token
- If you are not familiar with SSH keys, follow Hetzners How to SSH to create a new key pair
- enter your private key file as
hcloud_admin_priv_key_file
, eg.~/.ssh/id_rsa
- enter your public key file as
hcloud_admin_priv_key_file
, eg.~/.ssh/id_rsa.pub
- enter your private key file as
- simply follow this tutorial to generate your personal token
- Create a copy of server-init.tmpl.cfg called
server-init.cfg
within the sauerbraten subdirectry and edit it based on your wishes.- Take a look here to get some basic understanding of the available options.
To deploy the infrastructure and perform the server setup:
- Navigate to the terraform/ subdirectory of the cloned repository on your local machine.
- Run
terraform apply
to create the Hetzner Cloud server and firewall, and trigger Ansible for the server setup.- Confirm by typing
yes
when prompted.
- Confirm by typing
- Terraform will provision the infrastructure and output the IP address of the created server into inventory.yml based on the template from here.
- Ansible will then be triggered by terraform to connect to the server using SSH and apply the defined playbook based on the new inventory file.
- You can now execute further Ansible commands or playbooks using the generated inventory file.
- To keep your libraries on the servers host os up to date, you can use the command
ansible-playbook -i inventory.yml upgrade_playbook.yml
to run apt update and apt upgrade. - To update your game
- To keep your libraries on the servers host os up to date, you can use the command
To destroy the Hetzner Cloud infrastructure:
- Navigate to the terraform/ subdirectory of the cloned repository on your local machine.
- Run
terraform destroy
and confirm by typingyes
when prompted. - Terraform will destroy the created resources, including the Cloud Server, Firewall, and associated SSH keys.
Please note that destroying the infrastructure will result in the loss of any data stored on the Cloud Server.
Contributions are welcome! Please feel free to submit a pull request if you spot any issues or have any improvements to suggest.