TypeThoughts Blog by Pratyush

Using cloud-init to setup the servers quickly

We recently migrated the servers of our website Screener.in. One of the things that helped us complete the migration in 2 hours was the ease of setting up the server. We used cloud-init to automate the setup.

Cloud-init is a script that runs at the time of creation of the virtual machine. We use it to automate these things:
- setup a new user and add SSH keys
- set timezone of machine
- install postfix
- install docker and docker-compose
- setup directories which deploy the project on "git push"
- customise login messages

The script comes very handy whenever we are starting a new project. It also comes handy when we want to restart a project on a new droplet.

Cloud-init is part of Ubuntu's cloud server scripts. It is supported on almost all the hosting platforms including AWS, DigitalOcean or Vultr.

You can find the complete script here.