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

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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.
Accepted Answer
Your approach to using Terraform for provisioning infrastructure and Ansible for config management is the right way to think about it. Luckily Terraform should be able to do what you’d like. Pre-formatted volumes created via the API will be automatically mounted to the Droplet. So the key thing is to specify the initial_filesystem_type when creating the volume with Terraform. For example, using this config:
resource "digitalocean_droplet" "foo" {
name = "foo"
size = "s-1vcpu-1gb"
image = "ubuntu-18-04-x64"
region = "nyc1"
}
resource "digitalocean_volume" "bar" {
region = "nyc1"
name = "bar"
size = 100
initial_filesystem_type = "ext4"
description = "an example volume"
}
resource "digitalocean_volume_attachment" "foobar" {
droplet_id = "${digitalocean_droplet.foo.id}"
volume_id = "${digitalocean_volume.bar.id}"
}
The resulting volume will be mounted and available at /mnt/bar/ on the Droplet.
If you do not specify the initial_filesystem_type the volume will appear as a raw block device that must be manually formatted and mounted.