1. When making a thread, please tag your thread accordingly using the menu to the left of the textfield where you name your thread where applicable. Server Advertisements and Mod Releases should be contained to their respective subforums.

Tutorial Automate dedicated server setup with Ansible and Terraform

Discussion in 'Multiplayer' started by Shplorf, Aug 7, 2016.

  1. Shplorf

    Shplorf Space Hobo

    (X-Post from the Starbound subreddit)

    I've been really enjoying playing Starbound with friends on my dedicated server, so I thought I'd share my setup that makes it super easy to bring up and tear down.

    I do some DevOps-y stuff at work, so I'm pretty familiar with automation tools, infrastructure-as-code and all that jazz. So I wrote an Ansible role for Starbound. Once pointed at an Ubuntu server, it ensures Starbound is installed as a service that starts on boot. It also enables you to run commands to update the server or back-up/restore your universe from an S3 bucket (cloud storage). Here's the role:

    https://github.com/Shplorf/ansible-starbound

    Not satisfied with this, I also wanted to automate the actual creation of the server. I used Terraform to define a profile of an Ubuntu EC2 instance and a security group that only lets in SSH and Starbound connections. The Terraform configuration spins up the server, waits for it to come up, then uses the above Ansible script to install and configure Starbound:

    https://github.com/Shplorf/auto-starbound

    So basically, all I have to do is type the command "terraform apply" from my laptop's console and ~6 minutes later it spits out an IP of a dedicated server with my configuration (and optionally a restored universe) ready to go.

    I spend a good deal of time writing up the READMEs for these projects, and the documentation for both Terraform and Ansible is fantastic, so even though it may seem like a lot of stuff to set up, for me the convenience I end up with is worth it. Not to mention the satisfaction of typing one command and having a Starbound server magically appear.

    Ansible only works on Linux/OSX so this won't work on Windows out of the box. The extra step required would be to spin up an Ubuntu VM to run the commands from.

    I run my server on a t2.medium instance, which might be a bit too much, so depending on how many people you have playing at a time you may want to change the Terraform config to spin up a t2.small or t2.micro to save $$$. EC2 is expensive in general but the convenience is worth it to me. Self-hosting is obviously cheaper, which is why the Ansible role is its own separate thing and can be used with any Ubuntu (I only tested with Trusty) server.

    Comments/questions/pull requests welcome!

    If there is enough interest I might make a YouTube tutorial on setting this up.
     
    Yuis likes this.

Share This Page