Droplet: Run CentOS on DigitalOcean Cloud using Vagrant

DigitalOcean is a cloud infrastructure provider focused on the simplified cloud platform for developer and teams. if you are a developer who is looking for Simple and Minimalistic User Interface for deploying the application on Cloud for testing and hosting, DigitalOcean would be a better choice to start with.

Since I have started recently writing a blog about how to use Vagrant and VirtualBox in Ubuntu OS in the local system, I would like to explore the same procedure on Cloud using a Droplet rather than using VirtualBox Virtual Machine. You may think Why DigitalOcean while Azure or AWS is prominently known for Cloud Solution.

The reason behind is that DigitalOcean offers $100 free credit for a month to use their Cloud solution. So, I wanted to quickly use the offer for my testing.

  • Vagrant 2.2.2
  • DigitalOcean Account
  • Ubuntu 18.10
  • Basic command line knowledge
  • Make a DigitalOcean account and learn about the Droplet services.
  • Install Vagrant DigitalOcean Plugin
  • Create VagrantFile
  • Generate API Key
  • Bring up CentOS 7 Linux

Making a DigitalOcean Account

Go to DigitalOcean Site and sign up for an account. Once you sign up with UserID and Password, DigitalOcean will send you a confirmation mail. Just go ahead and click the confirmation, be prompted for your credit card and phone number. You will create your first project and choose the purpose of the project, if you interested further, you can let DigitalOcean know which Tool and Technologies to use for DigitalOcean and Click Start Button. Now You are in!.

Here is the dashboard with my First Project name.

About Droplet Services

DigitalOcean Droplets are flexible Linux-based virtual machines (VMs) that run on top of virtualized hardware. Each Droplet you create is a new server you can use. And, You have complete control over the server, what gets installed on it, the configuration and so on.

Install Vagrant DigitalOcean Plugin

Vagrant DigitalOcean Plugin allows us to expand the Vagrant capabilities to use Cloud Infrastructure. After installing the Vagrant, you can enable the Vagrant-plugin by using the following Command. If you are new to Vagrant and about the installation on Linux, I would recommend reading my previous post.

The displayed command below shows that there is no plugin installed in my system.

Let’s run vagrant-plugin to manage DigitalOcean Droplets.

if the installation is successful,  run vagrant plugin list command again to see the DigitalOcean plugin added in the list.

Create VagrantFile

Though vagrant init command will create a Vagrantfile, we need to know configuration values which need to support for creating Droplet in DigitalOcean. So, I looked around for a  vagrant plugin. I found in GitHub that there is a Vagrant DigitalOcean plugin that supports DigitalOcean Droplets to manage.  I lightly modified this and placed this in my Vagrantfile.  The key to note here is while copying the below vagrant configuration, Ensure that you have updated the VAGRANT_TOKEN which was generated using API Key. In the following section, I will explain the procedure about how to generate the API Key in DigitalOcean.

Generate API Key in DigitalOcean

The DigitalOcean API lets you programmatically manage your Droplets and other resources using conventional HTTP requests. Any action that you can perform through the DigitalOcean Control Panel (except for creating personal access tokens) can also be performed with the API.

In order to create a Droplet in DitigalOcean using Vagrant, you need to have an API key.  Click on API section on the dashboard in the DigitalOcean home page and Generate a Spaces Access Keys. Space Access keys are used for connecting third-party client such as AWS. Following that be prompted for creating Personal access token.

Provide a name for the key and Click Generate Token.

Your API token is generated now. As mentioned earlier, Copy the below displayed encrypted API token and update in Vagrantfile where  VAGRANT_TOKEN variable is defined.

Generate Key Pair

The default setting for a Linux server does not allow access via password – they use Key Pairs. Let’s generate ssh key pair using the below command.

Ensure that the above command has successfully generated the Public and Private key.

Bring up CentOS 7 using Vagrant up

Next, the last step as you are aware, Just run vagrant up command to bring up the droplet in DigitalOcean.

The above output looks fine without any error. Let’s run vagrant ssh command from shell to login to Droplet and type some Linux command to confirm the Version, Manufacture and so on.

Cool!. CentOS 7.5 is up and running on Droplet in DigitalOcean. You can see the newly created Droplet in DigitalOcean console as well.


We went over a lot in this article. Creating a DigitalOcean account, about Droplet services, Installing Vagrant DigitalOcean Plugin, accessing droplet using vagrant ssh command. Now we have a complete Cloud environment that can match a local environment for creating and destroying the instances.

Leave a Comment

Your email address will not be published. Required fields are marked *

5 − 2 =