Coder Social home page Coder Social logo

devopsgroup-io / vagrant-digitalocean Goto Github PK

View Code? Open in Web Editor NEW
1.7K 48.0 181.0 310 KB

:droplet: A Vagrant provider plugin that manages DigitalOcean droplets.

License: Mozilla Public License 2.0

Ruby 99.03% Shell 0.97%
devops digitalocean-droplets vagrant-plugin

vagrant-digitalocean's Introduction

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:

  • Create and destroy Droplets
  • Power on and off Droplets
  • Rebuild a Droplet (destroys and ups with same IP address)
  • Provision a Droplet with shell
  • Setup a SSH public key for authentication
  • Create a new user account during Droplet creation

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

  • You must specify the override.ssh.private_key_path to enable authentication with the Droplet. The provider will create a new DigitalOcean SSH key using your public key which is assumed to be the private_key_path with a .pub extension.
  • You must specify your DigitalOcean Personal Access Token at provider.token. This may be found on the control panel within the Apps & API section.

Supported Configuration Attributes

The following attributes are available to further configure the provider:

  • provider.image
    • A string representing the image to use when creating a new Droplet. It defaults to ubuntu-18-04-x64. List available images with the vagrant digitalocean-list images $DIGITAL_OCEAN_TOKEN command. Like when using the DigitalOcean API directly, it can be an image ID or slug.
  • provider.ipv6
    • A boolean flag indicating whether to enable IPv6
  • provider.region
    • A string representing the region to create the new Droplet in. It defaults to nyc2. List available regions with the vagrant digitalocean-list regions $DIGITAL_OCEAN_TOKEN command.
  • provider.size
    • A string representing the size to use when creating a new Droplet (e.g. s-1vcpu-1gb). It defaults to s-1vcpu-1gb. List available sizes with the vagrant digitalocean-list sizes $DIGITAL_OCEAN_TOKEN command.
  • provider.private_networking
    • A boolean flag indicating whether to enable a private network interface (if the region supports private networking). It defaults to false.
  • provider.backups_enabled
    • A boolean flag indicating whether to enable backups for the Droplet. It defaults to false.
  • provider.ssh_key_name
    • A string representing the name to use when creating a DigitalOcean SSH key for Droplet authentication. It defaults to Vagrant.
  • provider.setup
    • A boolean flag indicating whether to setup a new user account and modify sudo to disable tty requirement. It defaults to true. If you are using a tool like Packer to create reusable snapshots with user accounts already provisioned, set to false.
  • provider.monitoring
    • A boolean indicating whether to install the DigitalOcean agent for monitoring. It defaults to false.
  • provider.tags
    • A flat array of tag names as strings to apply to the Droplet after it is created. Tag names can either be existing or new tags.
  • provider.volumes
    • A flat array including the unique identifier for each Block Storage volume attached to the Droplet.
  • config.vm.synced_folder
    • Supports both rsync__args and rsync__exclude, see the Vagrant Docs for more information. rsync__args default to ["--verbose", "--archive", "--delete", "-z", "--copy-links"] and rsync__exclude defaults to [".vagrant/"].

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:

  • vagrant destroy - Destroys the Droplet instance.
  • vagrant ssh - Logs into the Droplet instance using the configured user account.
  • vagrant halt - Powers off the Droplet instance.
  • vagrant provision - Runs the configured provisioners and rsyncs any specified config.vm.synced_folder.
  • vagrant reload - Reboots the Droplet instance.
  • vagrant rebuild - Destroys the Droplet instance and recreates it with the same IP address which was previously assigned.
  • vagrant status - Outputs the status (active, off, not created) for the Droplet instance.

Compatibility

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

Date Tested Vagrant Version vagrant-digitalocean Version Host (Workstation) Operating System Guest (DigitalOcean) Operating System
03/12/2020 2.2.7 0.9.4 OS X 10.14.6 Ubuntu 18.04, Debian 10, Debian 9, Debian 8, CentOS 7
03/22/2016 1.8.1 0.7.10 OS X 10.11.4 CentOS 7.0
04/03/2013 1.1.5 0.1.0 Ubuntu 12.04 CentOS 6.3

Troubleshooting

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

  • For the latest Vagrant version, please visit the Vagrant website

  • To update Vagrant plugins, run the following command: vagrant plugin update

  • vagrant plugin install vagrant-digitalocean

    • Installation on OS X may not working due to a SSL certificate problem, and you may need to specify a certificate path explicitly. To do so, run ruby -ropenssl -e "p OpenSSL::X509::DEFAULT_CERT_FILE". Then, add the following environment variable to your .bash_profile script and source it: export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem.

FAQ

  • The Chef provisioner is no longer supported by default (as of 0.2.0). Please use the vagrant-omnibus plugin to install Chef on Vagrant-managed machines. This plugin provides control over the specific version of Chef to install.

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

vagrant-digitalocean's People

Contributors

bradisbell avatar estevesd avatar fullyint avatar hendrikb avatar hiroraba avatar ijin avatar javier-lopez avatar jfarrell avatar jfifield avatar johnbender avatar jtreminio avatar mccahan avatar merty avatar mtessar avatar napcs avatar nwertzberger avatar pascalj avatar rickw avatar rjsamson avatar sergey-korolev avatar seth-reeser avatar shanemgrey avatar simoniong avatar smdahlen avatar syrusakbary avatar tchebb avatar tmatilai avatar wizonesolutions avatar wnoguchi avatar xstasi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vagrant-digitalocean's Issues

Setup Travis CI tests

Shouldn't be too hard to run integration tests on each of the commands for each push. Should probably setup a test account over on DO though.

Repeatable error with rsync folder protocol

Trying to run a vagrant provision to push new content to the droplet.

Host path: ~/ops/prod/public-apache/sync/
Guest path: /sync
Error: bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]

Quick fix may be to follow the advice here in this thread.
http://samba.2283325.n4.nabble.com/rsync-3-0-9-incompatible-with-self-proto-incompat-on-local-gt-local-td4635345.html

Specifically "You can work around it by specifying --no-inc-recursive (--no-i-r)." was suggested.

Sync active machine state with droplet status

Currently, Vagrant must be run on a single workstation since machine state is saved locally to disk. Specifically, the ID of the droplet is saved with the machine name to disk. To enable multiple users (or CI infrastructure) to run Vagrant on the same project, this issue will check for active droplets in Digital Ocean and synchronize with machine state locally.

Feature Idea : Specify Hostname

Its seems that unless I modify it with later with a bunch of API commands, the hostname is always set to "default" and it should be possible to specify it somehow before its created.

rsync ignore files

Maybe it would be a good idea to implement a configurable list of files / folders to ignore while rsyncing.

For example in nodejs it is not very wise to rsync the folder node_modules cause it can be very big and npm install && npm update on the server are run anyways via provisioning to recreate the contents of node_modules.

* The box 'digital_ocean' could not be found.

I'm getting the error

* The box 'digital_ocean' could not be found.

I've ran

vagrant box add digital_ocean https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box

But I checked the ~/.vagrant.d/boxes/digital_ocean folder and only a metadata.json file exists

How to provision multiple droplets of varying sizes?

I'm trying to use the following in my Vagrantfile to provision certain droplets with higher specs than my baseline, but I can't seem to find the right syntax - is it actually possible?

I get:

Vagrant:
* Unknown configuration section 'size='.

Relevant config:

config.vm.provider :digital_ocean do |docean, override|
  docean.client_id = ENV.fetch('DO_CLIENT_ID') { abort "add DO_CLIENT_ID" }
  docean.api_key = ENV.fetch('DO_API_KEY') { abort "add DO_API_KEY" }
  docean.image = 'Ubuntu 12.04 x64'
  docean.region = DO_LOCATION
  docean.size = "#{DO_SIZE}GB" || "2GB"

  override.ssh.username = ENV.fetch('DO_SSH_USER') { abort "add DO_SSH_USER" }
  override.ssh.private_key_path = ENV.fetch('DO_PRIV_KEY') { abort "add DO_PRIV_KEY" }
  override.vm.box = "digitalocean_precise"
  override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
end

config.vm.define :redis do |redis|
  redis.vm.hostname = "wave-logstack-redis"
  redis.hostmanager.aliases = "redis redis.example.com"
  redis.size = "4GB"
  redis.vm.provision :hostmanager
  redis.vm.provision :chef_solo do |chef|
    chef.data_bags_path = "data_bags"
    chef.node_name = "example-logstack-redis"
    chef.add_recipe "example-base"
    chef.add_recipe "example-redis"
  end
end

config.vm.define :logstash, primary: true do |logstash|
  logstash.vm.hostname = "example-logstack-logstash"
  logstash.hostmanager.aliases = "logstash logs.example.com"
  logstash.vm.provision :hostmanager
  logstash.size = "8GB"
  logstash.vm.provision :chef_solo do |chef|
    chef.data_bags_path = "data_bags"
    chef.node_name = "example-logstack-logstash"
    chef.add_recipe "example-base"
    chef.add_recipe "example-logstash"
  end
end

Local testing

This is cool, thanks!
What's the best way to do local testing before pushing to digital_ocean?

NFS cleanup

Subsequent ups put nfs in a bad state. Most likely I need to borrow the cleanup code from the virtualbox provider actions.

Provide in-depth documentation e.g. wiki-page(s)

Please provide more in-depth documentation on how to use this (very promising!) plugin.
ATM I'm running into issues (on OS X Lion) with a droplet being created and destroyed immediately afterwards, followed by NFS related issues. See screenshot:

Screen Shot 2013-03-16 at 4 19 52 PM

I am unsure if this is related to not having any provisioner enabled in the Vagrantfile yet, like Chef solo.

BTW I managed to get by the ca_path related issues by simply copying the Git-files into the Vagrant gems-directory, but I doubt if that is the right way to use the latest plugin-code.

starting the wrong droplet with vagrant 1.4

Since I upgraded to vagrant 1.4 yesterday, the digital ocean plugin starts the wrong Droplet. My workflow is like this (Vagrantfile, image.json):

$ packer build --only=digitalocean image.json
# creates a docker_digitalocean.box file

$ vagrant up --provider=digital_ocean
# uses the docker_digitalocean.box file via the box_url parameter

Bevor upgrading to 1.4 the DO plugin would use the 'docker_digitalocean.box' file created by packer, import it and start the right image. But now the box-file is not imported and some other, maybe default, image is started ...

If I manually import the box file prior to starting it, with:

$ vagrant box add docker docker_digitalocean.box

The right image is used!

bash: rsync: command not found

Hi

Having an issue when creating new droplet on digital ocean, not sure if this is an issue with digitalocean_provider or directly with vagrant:

bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: remote command not found (code 127) at io.c(605) [sender=3.0.9]

There is an rsync bash file in /etc/bash_completion.d/

Everything else deploys fine, can ssh to droplet etc.

My machine:
Ubuntu 12.04
Vagrant 1.2.2

Vagrantfile:

Vagrant.configure('2') do |config|
config.omnibus.chef_version = :latest
config.ssh.private_key_path = "~/.ssh/id_rsa"
config.ssh.username = 'NAME'
config.vm.box = "digital_ocean"
config.vm.hostname = 'NAME'
config.vm.provider :digital_ocean do |provider|
provider.client_id = "v*********************H"
provider.api_key = "o**
*****************************R"
provider.region = "Amsterdam 1"
provider.image = "Ubuntu 10.04 x32 Server"
provider.size = "512MB"
provider.ssh_key_name = 'NAME'

end

config.vm.provider :digital_ocean do |vm|
vm.ca_path = '/etc/ssl/certs/ca-certificates.crt'
end

end

Any help appreciated. Thanks, Rob

Support arbitrary key pair

Allow the user to specify a public and private keypair of their own choosing. Currently it defaults to the insecure vagrant keys.

vagrant 1.2.1, trying to vagrant up and getting problem reading public key

using lastest vagrant-digitalocean gem plugin and vagrant 1.2.1, trying to vagrant up and getting problem reading public key:

vagrant up --provider=digital_ocean
Bringing machine 'default' up with 'digital_ocean' provider...
There was an issue reading the public key at:

Path: ~/.ssh/id_rsa.pub

Please check the file's permissions.

got file perms on both private and public 0600, also tried 0644 didn't work

also got the latest brew install curl-ca-bundle and added the export to the .bash_profile and the env var is available..

Any ideas?

Can't install plugin

Im getting an issue when trying to install the plugin. Not sure how to fix this.

Installing the 'vagrant-digitalocean' plugin. This can take a few minutes...
/opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:562:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /opt/vagrant/embedded/bin/ruby extconf.rb
creating Makefile

make
compiling generator.c
In file included from /opt/vagrant/embedded/include/ruby-1.9.1/ruby.h:32:0,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
/opt/vagrant/embedded/include/ruby-1.9.1/ruby/ruby.h:105:14: error: size of array ‘ruby_check_sizeof_long’ is negative
/opt/vagrant/embedded/include/ruby-1.9.1/ruby/ruby.h:109:14: error: size of array ‘ruby_check_sizeof_voidp’ is negative
In file included from /opt/vagrant/embedded/include/ruby-1.9.1/ruby/intern.h:43:0,
                 from /opt/vagrant/embedded/include/ruby-1.9.1/ruby/ruby.h:1383,
                 from /opt/vagrant/embedded/include/ruby-1.9.1/ruby.h:32,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
/opt/vagrant/embedded/include/ruby-1.9.1/ruby/st.h:67:14: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
make: *** [generator.o] Error 1


Gem files will remain installed in /home/aaron/.vagrant.d/gems/gems/json-1.8.0 for inspection.
Results logged to /home/aaron/.vagrant.d/gems/gems/json-1.8.0/ext/json/ext/generator/gem_make.out
    from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:540:in `block in build_extensions'
    from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:515:in `each'
    from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:515:in `build_extensions'
    from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:180:in `install'
    from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:297:in `block in install'
    from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each'
    from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `each_with_index'
    from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in `install'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/commands/plugin/action/install_gem.rb:49:in `block in call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/commands/plugin/gem_helper.rb:42:in `block in with_environment'
    from /opt/vagrant/embedded/lib/ruby/1.9.1/rubygems/user_interaction.rb:40:in `use_ui'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/commands/plugin/gem_helper.rb:41:in `with_environment'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/commands/plugin/action/install_gem.rb:39:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/commands/plugin/action/bundler_check.rb:20:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/action/runner.rb:61:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/action/runner.rb:61:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/commands/plugin/command/base.rb:17:in `action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/commands/plugin/command/install.rb:44:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/commands/plugin/command/root.rb:47:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/cli.rb:46:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/lib/vagrant/environment.rb:478:in `cli'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.2.7/bin/vagrant:84:in `<top (required)>'
    from /opt/vagrant/bin/../embedded/gems/bin/vagrant:23:in `load'
    from /opt/vagrant/bin/../embedded/gems/bin/vagrant:23:in `<main>'

Can't turn off rsync prior to provisioning

My use case is running this as a provider and provisioning with Ansible. Every time I run it, it rsyncs my local directory to /vagrant on the DigitalOcean instance. I have some someone large files, and Ansible doesn't need them on DO - it copies them itself.. I've tried to turn it off with

config.vm.synced_folder "/vagrant", ".", disabled: true

and some variations. It seems to just ignore my directive and rsync away. Can it be turned off?

Thanks for this cool plugin!

SSL Certs on OSX

Faraday needs the ssl certs path. No clue how to provide that on OSX :/

The box 'digital_ocean' could not be found.

Sorry to be a pain :-)

I have correctly installed the provider, and downloaded the box, and created a Vagrantfile, but on vagrant up I get the following:

vm:

  • The box 'digital_ocean' could not be found.

Screen Shot 2013-04-09 at 22 33 19

Puppet support

From the doc it seems only chef it is supported.
Vagrant should support both out of the box, or this should just be fixed in some way?

progress bar on rsync upload

Could we please add a progress bar of some sort for the rsync? I'm watching my current upload for 15min and I am not sure if its working or how long its got to go.

Perhaps we just add the --progress flag for rsync command?

add port forwarding to ssh

I would like port forwarding to work on digital ocean just as it does with the default provider.

I can work around it using vagrant ssh-config and then adding the forwarding commands manually, but that defeats the purpose of DRY configuration (Don't Repeat Yourself).

(In https://github.com/ianheggie/salted-rails (vagrant plugin) I auto configure the forwarding ports, so its a backwards step to have to then do them manually)

Managing existing droplets?

Hi,

I have an existing Digital Ocean droplet and I'd like to manage it using Vagrant instead of having to create a new one.

How do I use the plugin to hook into existing droplets on Digital Ocean?

Cheers,

-- Attila

Provide a sync folders command

Provide a command to execute the rsync logic for syncing folders from the host to guest machine. This command can be used by watcher scripts to automate the syncing of file changes on the host.

Doesn't complete vagrant up

Hi,

I'm using this vagrant file:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") 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/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"

    provider.ca_path = "/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt"
    provider.client_id = "my_id"
    provider.api_key = "my_key"
    provider.image = "Ubuntu 12.04 x64"
    provider.region = "San Francisco 1"
  end

  # PROD - digital ocean environment
  # ---------------------------------------
  config.vm.define :prod do |prod|
    prod.omnibus.chef_version = "10.14.2"

    prod.vm.provision :chef_solo do |chef|
      chef.add_recipe "git"
      chef.add_recipe "nodejs::install_from_package"
      chef.add_recipe "mongodb::10gen_repo"
      chef.add_recipe "mongodb::default"
    end

    prod.berkshelf.enabled = true
  end
end

But when I try the vagrant get up using digital ocean provider, I`m getting the error bellow:

sudo vagrant up --provider=digital_ocean
Bringing machine 'prod' up with 'digital_ocean' provider...
[prod] Creating new SSH key: Vagrant...
[prod] Creating a new droplet...
[prod] Assigned IP address: 192.241.208.138
[prod] Destroying the droplet...
/Users/maxcnunes/.vagrant.d/gems/gems/vagrant-digitalocean-0.3.0/lib/vagrant-digitalocean/actions/create.rb:61:in `block in call': not ready (RuntimeError)
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/util/retryable.rb:17:in `retryable'
  from /Users/maxcnunes/.vagrant.d/gems/gems/vagrant-digitalocean-0.3.0/lib/vagrant-digitalocean/actions/create.rb:59:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/warden.rb:34:in `call'
  from /Users/maxcnunes/.vagrant.d/gems/gems/vagrant-digitalocean-0.3.0/lib/vagrant-digitalocean/actions/setup_key.rb:33:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/warden.rb:34:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/runner.rb:61:in `block in run'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/util/busy.rb:19:in `busy'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/runner.rb:61:in `run'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/builtin/call.rb:51:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/warden.rb:34:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/warden.rb:34:in `call'
  from /Users/maxcnunes/.vagrant.d/gems/gems/vagrant-berkshelf-1.3.3/lib/berkshelf/vagrant/action/configure_chef.rb:23:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/warden.rb:34:in `call'
  from /Users/maxcnunes/.vagrant.d/gems/gems/vagrant-berkshelf-1.3.3/lib/berkshelf/vagrant/action/load_shelf.rb:28:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/warden.rb:34:in `call'
  from /Users/maxcnunes/.vagrant.d/gems/gems/vagrant-berkshelf-1.3.3/lib/berkshelf/vagrant/action/set_ui.rb:12:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/warden.rb:34:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/builtin/env_set.rb:19:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/warden.rb:34:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/builder.rb:116:in `call'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/runner.rb:61:in `block in run'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/util/busy.rb:19:in `busy'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/action/runner.rb:61:in `run'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/machine.rb:147:in `action'
  from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.3/lib/vagrant/batch_action.rb:63:in `block (2 levels) in run'

Seems the @machine.communicate.ready? is not getting completed never:

retryable(:tries => 120, :sleep => 10) do
  next if env[:interrupted]
  raise 'not ready' if !@machine.communicate.ready?
end

Should I increase the tries? Does anyone know what I could do make this work?

Cheers,

Ability to use Image Snapshots instead of standard OS images

Hi,

Extra thanks for this provider, very useful !

It seems like the provider.image field only accepts the standard os images, DigitalOcean supports launching droplets from snapshots/backups, that will be extra cool instead of launching the base image then doing customizations before triggering the chef run ..

Thanks.

SetupUser fails if pattern match even if the match is not a user

Hello,

Thanks for the great work on this plugin, I'm new to vagrant and this plugin has been the only one I've found to use my digitalocean droplets. I've tried to setup a machine with the following setting:

override.ssh.username = 'admin'

And I've noticed it fails due to this line:

if ! (grep #{user} /etc/sudoers); then
echo "#{user} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers;
fi
DEBUG ssh: stdout: gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh

https://github.com/smdahlen/vagrant-digitalocean/blob/f8d1bc58d93b508450ceb5b8be272988ac76c75a/lib/vagrant-digitalocean/actions/setup_user.rb#L35

It's matching any string, on this example (admin) which is not a user, but a description of the gnats user, who already exist on the system, after vagrant passes this line, it 'thinks' admin already exist and continue without creating him, which will eventually make the process fail without apparent reason:

INFO ssh: Execute: su admin -c 'mkdir -p ~/.ssh' (sudo=false)
DEBUG ssh: stderr: stdin: is not a tty

DEBUG ssh: stderr: Unknown id: admin

DEBUG ssh: Exit status: 1

I'd suggest to replace the above line with:

if ! (grep ^#{user}: /etc/sudoers); then
echo "#{user} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers;
fi

So it can only match true users and not any string on the file.

Support configurable SSH user

Allow the user to specify the SSH user for login using the standard Vagrant configuration attributes. The root username should be used on the vagrant up command for initial provisioning. If the user provisions another account during bootstrap, that account can be used in subsequent SSH requests.

Plugin not aligned with DigitalOcean API?

Hey,

I had an initial issue with this plugin relating to the name of the image set by default. I noticed that the API listed 'Ubuntu 12.04 x64" instead of the plugin's default "Ubuntu 12.04 x64 Server".

Additionally, I get the following:

There was an issue with the request made to the Digital Ocean
API at:

Path: /droplets/new
URI Params: {:size_id=>66, :region_id=>1, :image_id=>284203, :name=>:do_app, :ssh_key_ids=>27344, :client_id=>"WUyPUMZ295eOwy7WLaave", :api_key=>"REMOVED"}

The response status from the API was:

Status: ERROR
Response: {"status"=>"ERROR", "error_message"=>{"name"=>["Only valid hostname characters are allowed. (a-z, A-Z, 0-9, . and -)"]}}

Here is my Vagrantfile:

config.vm.define :do_app do |c|
    c.ssh.private_key_path = "~/.ssh/id_rsa"
    c.vm.box = "digital_ocean"
    c.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
    c.vm.provider :digital_ocean do |provider|
      provider.client_id = "MY_CLIENT_ID"
      provider.api_key = "MY_API_KEY"

      provider.image = "Ubuntu 12.04 x64" 
      # remember to: $ export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
      provider.ca_path = "/etc/ssl/certs/ca-certificates.crt"
    end
  end

Anyone else having this issue?

IP Address & Provisioning with Ansible

We're using your excellent plugin to deploy to DO - and see that you're getting the IP address of the droplet back.

We're using Ansible to provision the servers, however it needs an ip address in its inventory file in order to provision the machine.

Is there a way we can access the IP address returned to pass it into ansible (or at least write it to a file on disk?

First class support for provisioning with Salt.

Salt works for provisioning on most of the images from what I can see, however you may need to make some tweaks I havent spotted in my testing. Really just want to see the claim that chef is the only way to provision droplets, changed since its disingenuous with both Salt and Shell provisioners working.

http://saltstack.org

Support suspend/resume

This appears to be possible as long as the snapshot id is available from the API. Then it's simply a call to the restore endpoint.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.