Report this

What is the reason for this report?

How do you script a custom droplet?

Posted on February 12, 2015

I’d like to be able to write some scripts to completely automate the creation of WordPress droplets on Ubuntu Server. But, I’d like customized WordPress droplets that are not currently offered in the Digital Ocean droplet creation UI.

For example…I’d like the WordPress droplets to run on Nginx on Ubuntu instead of Apache. The Digital Ocean WordPress application runs on Apache while the LEMP application install does not include WordPress.

Neither instance has a firewall enabled - which Digital Ocean does recommend doing once the droplet is created.

Neither instance includes Varnish, which may help with page load times.

While I can look up how to manually enable the firewall, how to install WordPress on LEMP and even how to install Varnish…I would like to be able to script all of this (starting with using the Digital Ocean v2 API) so that I can create my own web UI to start an instance of WordPress on LEMP with Varnish and the firewall configured and ready to go.

Doing this all via scripting seems like it would save a lot more time than manually setting everything up for each server.

How would you go about doing this? Are there any tutorials on scripting this sort of thing?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

@ryanpq Isn’t easier to just use the DigitalOcean API and create a new droplet, and then use SSH to install required programs?

Speaking of which, where can I find the formal names of the droplet OS distributions?

Internally we use scripts written to use Fabric to install and configure the software needed to create the master images for our one clicks. It’s really quite easy to start using, even if you are not very familiar with Python and will allow you to script custom deployments so you would simply launch a droplet with the OS you want to start with (either from the control panel or API) and then execute your fabric script against the new IP address.

There are of course many different approaches that you could take. You could use one of the various configuration management tools like Chef, Ansible, or Fabric to script this.

Another option is to pass a script in the “user-data” when creating a new droplet. This allows you to provide a script that will run on first boot of the droplet. For more advance usages, check out these tutorials on cloud-config scripting:

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.