Hello, my name is John Flynn. I am a tech enthusiast, maker and tinkerer. This is my blog where I write about stuff.

tags

I spent the past weekend messing around with Python and a couple of libraries to automate the deployment of droplets to Digital Ocean. The two libraries that I used are python digitalocean and fabric. Python digitalocean opens up the Digital Ocean API to python developers with easy to use functions. Fabric provides a way of connecting to a remote server and issuing various commands, so the combination of the two make for a great automation framework. The script I wrote, uses the python_digitalocean library to first provision the droplet and returns the IP. Then fabric is used to carry out several first time administration tasks that I do when first creating a server. These are:

  1. Update the newly provisioned system.
  2. Create an admin user for the box, and copy my SSH public key to the account.
  3. Grant sudo privileges to the user that was created above.
  4. Secure SSH by disabling root logon, password authentication and changing the listening port.
  5. Configure UFW to only allow connections to the port that SSH is listening on.
  6. Configure unattended security updates (probably not a good idea in a prod environment).

Where do I download this script?

I have placed the script on github here. Clone the repo and try it out, let me know if you have any suggestions to extend the script.

comments powered by Disqus