Infra revisited

Using Terraform and Cloud-Init

Devops

More than ten years ago I wrote a series of articles on provisioning servers using DigitalOcean, Vagrant and SaltStack. Since then, a lot has changed.

Managing VMs and local testing

First of all, I stopped using Vagrant. The idea was to replicate the eventual infrastructure locally, but this just does not work. Most cloud provider modules cannot be reproduced with just VMs. I now believe it’s better to just spin up a development infrastructure on the targeted cloud provider, and test against that.

I am now firmly in the Terraform camp.

Provisioning

Secondly, I’ve decided that most provisioning tools suck. Tools like Puppet and SaltStack require all kinds of additional software to be installed on your VMs. Tools like Ansible are slightly better, but you need to duplicate a lot of information that is already present in Terraform. This can be done, and I’ve actually done it, but it always feels like a hack.

Finally, those provisioning tools are not as idempotent as they want you to believe. The only way to ensure your server is exactly what you want it to be, is to destroy and rebuild it over and over again.

Cloud-Init

Combining this goal with my preference for Terraform results in only one option: Cloud-init. The upcoming series of articles investigates a non-trivial cloud set-up on DigitalOcean using Terraform and cloud-init.