Home

Awesome

DigitalOcean Vagrant Provider

Gem Gem Gem Twitter

vagrant-digitalocean is a Vagrant provider plugin that supports the management of DigitalOcean Droplets (virtual machines).

Features include:

Install

Install the provider plugin using the Vagrant command-line interface:

vagrant plugin install vagrant-digitalocean

Configure

Once the provider has been installed, you will need to configure your project to use it. See the following example for a basic multi-machine Vagrantfile implementation that manages two DigitalOcean Droplets running Ubuntu 18.04 using a single CPU Droplet with 1GB of memory:

Vagrant.configure('2') do |config|

  config.vm.define "droplet1" do |config|
      config.vm.provider :digital_ocean do |provider, override|
        override.ssh.private_key_path = '~/.ssh/id_rsa'
        override.vm.box = 'digital_ocean'
        override.vm.box_url = "https://github.com/devopsgroup-io/vagrant-digitalocean/raw/master/box/digital_ocean.box"
        override.nfs.functional = false
        override.vm.allowed_synced_folder_types = :rsync
        provider.token = 'YOUR TOKEN'
        provider.image = 'ubuntu-18-04-x64'
        provider.region = 'nyc1'
        provider.size = 's-1vcpu-1gb'
        provider.backups_enabled = false
        provider.private_networking = false
        provider.ipv6 = false
        provider.monitoring = false
      end
  end

  config.vm.define "droplet2" do |config|

      config.vm.provider :digital_ocean do |provider, override|
        override.ssh.private_key_path = '~/.ssh/id_rsa'
        override.vm.box = 'digital_ocean'
        override.vm.box_url = "https://github.com/devopsgroup-io/vagrant-digitalocean/raw/master/box/digital_ocean.box"
        override.nfs.functional = false
        override.vm.allowed_synced_folder_types = :rsync
        provider.token = 'YOUR TOKEN'
        provider.image = 'ubuntu-18-04-x64'
        provider.region = 'nyc3'
        provider.size = 's-1vcpu-1gb'
        provider.backups_enabled = false
        provider.private_networking = false
        provider.ipv6 = false
        provider.monitoring = false
      end
  end

end

Configuration Requirements

Supported Configuration Attributes

The following attributes are available to further configure the provider:

The provider will create a new user account with the specified SSH key for authorization if config.ssh.username is set and the provider.setup attribute is true.

Run

After creating your project's Vagrantfile with the required configuration attributes described above, you may create a new Droplet with the following command:

$ vagrant up --provider=digital_ocean

This command will create a new Droplet, setup your SSH key for authentication, create a new user account, and run the provisioners you have configured.

Supported Commands

The provider supports the following Vagrant sub-commands:

Compatibility

This DigitalOcean API provider plugin for Vagrant has been tested with the following technology.

Date TestedVagrant Versionvagrant-digitalocean VersionHost (Workstation) Operating SystemGuest (DigitalOcean) Operating System
03/12/20202.2.70.9.4OS X 10.14.6Ubuntu 18.04, Debian 10, Debian 9, Debian 8, CentOS 7
03/22/20161.8.10.7.10OS X 10.11.4CentOS 7.0
04/03/20131.1.50.1.0Ubuntu 12.04CentOS 6.3

Troubleshooting

Before submitting a GitHub issue, please ensure both Vagrant and vagrant-digitalocean are fully up-to-date.

FAQ

Contribute

To contribute, fork then clone the repository, and then the following:

Developing

  1. Install RVM
  2. If using MacOS, follow these OpenSSL instructions
  3. Use Ruby v3.0.0 rvm use 3.0.0
  4. Run bundle install

Testing

  1. Build and package your newly developed code:
    • rake gem:build
  2. Then install the packaged plugin:
    • vagrant plugin install pkg/vagrant-digitalocean-*.gem
  3. Once you're done testing, roll-back to the latest released version:
    • vagrant plugin uninstall vagrant-digitalocean
    • vagrant plugin install vagrant-digitalocean
  4. Once you're satisfied developing and testing your new code, please submit a pull request for review.

Releasing

To release a new version of vagrant-digitalocean you will need to do the following:

(only contributors of the GitHub repo and owners of the project at RubyGems will have rights to do this)

  1. First, bump, commit, and push the version in ~/lib/vagrant-digitalocean/version.rb:
  2. Then, create a matching GitHub Release (this will also create a tag):
  3. You will then need to build and push the new gem to RubyGems:
    • rake gem:build
    • gem push pkg/vagrant-digitalocean-0.7.6.gem
  4. Then, when John Doe runs the following, they will receive the updated vagrant-digitalocean plugin:
    • vagrant plugin update
    • vagrant plugin update vagrant-digitalocean