From 8e661906e1dd5ad92d39be4a4587ee504905fbb1 Mon Sep 17 00:00:00 2001 From: David Esteves Date: Fri, 20 Jan 2017 13:28:57 +0400 Subject: [PATCH 1/2] Add support for "tags" and "monitoring" options --- README.md | 10 +++++++--- lib/vagrant-digitalocean/actions/create.rb | 4 +++- lib/vagrant-digitalocean/config.rb | 6 ++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9ff11cf..d3c1049 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Vagrant.configure('2') do |config| provider.size = '512mb' end end - + config.vm.define "droplet2" do |config| config.vm.provider :digital_ocean do |provider, override| override.ssh.private_key_path = '~/.ssh/id_rsa' @@ -54,7 +54,7 @@ Vagrant.configure('2') do |config| provider.size = '1gb' end end - + end ``` @@ -82,6 +82,10 @@ The following attributes are available to further configure the provider: * 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](https://packer.io) 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. - `config.vm.synced_folder` * Supports both rsync__args and rsync__exclude, see the [Vagrant Docs](http://docs.vagrantup.com/v2/synced-folders/rsync.html) for more information. rsync__args default to `["--verbose", "--archive", "--delete", "-z", "--copy-links"]` and rsync__exclude defaults to `[".vagrant/"]`. @@ -126,7 +130,7 @@ Before submitting a GitHub issue, please ensure both Vagrant and vagrant-digital * For the latest Vagrant version, please visit the [Vagrant](https://www.vagrantup.com/) website * To update Vagrant plugins, run the following command: `vagrant plugin update` -* `vagrant plugin install vagrant-digitalocean` +* `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`. diff --git a/lib/vagrant-digitalocean/actions/create.rb b/lib/vagrant-digitalocean/actions/create.rb index c909968..45c993c 100644 --- a/lib/vagrant-digitalocean/actions/create.rb +++ b/lib/vagrant-digitalocean/actions/create.rb @@ -27,7 +27,9 @@ def call(env) :private_networking => @machine.provider_config.private_networking, :backups => @machine.provider_config.backups_enabled, :ipv6 => @machine.provider_config.ipv6, - :user_data => @machine.provider_config.user_data + :user_data => @machine.provider_config.user_data, + :monitoring => @machine.provider_config.monitoring, + :tags => @machine.provider_config.tags }.delete_if { |k, v| v.nil? }) # wait for request to complete diff --git a/lib/vagrant-digitalocean/config.rb b/lib/vagrant-digitalocean/config.rb index 7593347..26ba50e 100644 --- a/lib/vagrant-digitalocean/config.rb +++ b/lib/vagrant-digitalocean/config.rb @@ -12,6 +12,8 @@ class Config < Vagrant.plugin('2', :config) attr_accessor :ssh_key_name attr_accessor :setup attr_accessor :user_data + attr_accessor :monitoring + attr_accessor :tags alias_method :setup?, :setup @@ -27,6 +29,8 @@ def initialize @ssh_key_name = UNSET_VALUE @setup = UNSET_VALUE @user_data = UNSET_VALUE + @monitoring = UNSET_VALUE + @tags = UNSET_VALUE end def finalize! @@ -41,6 +45,8 @@ def finalize! @ssh_key_name = 'Vagrant' if @ssh_key_name == UNSET_VALUE @setup = true if @setup == UNSET_VALUE @user_data = nil if @user_data == UNSET_VALUE + @monitoring = false if @monitoring == UNSET_VALUE + @tags = nil if @tags == UNSET_VALUE end def validate(machine) From 18499217d02c79eae264e22334b8ff1a2c49de6e Mon Sep 17 00:00:00 2001 From: David Esteves Date: Wed, 7 Jun 2017 12:46:27 +0400 Subject: [PATCH 2/2] Add support for attaching Block Storage Volume to the droplet --- README.md | 2 ++ lib/vagrant-digitalocean/actions/create.rb | 3 ++- lib/vagrant-digitalocean/config.rb | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3c1049..0c236e5 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,8 @@ The following attributes are available to further configure the provider: * 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](http://docs.vagrantup.com/v2/synced-folders/rsync.html) for more information. rsync__args default to `["--verbose", "--archive", "--delete", "-z", "--copy-links"]` and rsync__exclude defaults to `[".vagrant/"]`. diff --git a/lib/vagrant-digitalocean/actions/create.rb b/lib/vagrant-digitalocean/actions/create.rb index 45c993c..80318c5 100644 --- a/lib/vagrant-digitalocean/actions/create.rb +++ b/lib/vagrant-digitalocean/actions/create.rb @@ -29,7 +29,8 @@ def call(env) :ipv6 => @machine.provider_config.ipv6, :user_data => @machine.provider_config.user_data, :monitoring => @machine.provider_config.monitoring, - :tags => @machine.provider_config.tags + :tags => @machine.provider_config.tags, + :volumes => @machine.provider_config.volumes }.delete_if { |k, v| v.nil? }) # wait for request to complete diff --git a/lib/vagrant-digitalocean/config.rb b/lib/vagrant-digitalocean/config.rb index 26ba50e..eda9e55 100644 --- a/lib/vagrant-digitalocean/config.rb +++ b/lib/vagrant-digitalocean/config.rb @@ -14,6 +14,7 @@ class Config < Vagrant.plugin('2', :config) attr_accessor :user_data attr_accessor :monitoring attr_accessor :tags + attr_accessor :volumes alias_method :setup?, :setup @@ -31,6 +32,7 @@ def initialize @user_data = UNSET_VALUE @monitoring = UNSET_VALUE @tags = UNSET_VALUE + @volumes = UNSET_VALUE end def finalize! @@ -47,6 +49,7 @@ def finalize! @user_data = nil if @user_data == UNSET_VALUE @monitoring = false if @monitoring == UNSET_VALUE @tags = nil if @tags == UNSET_VALUE + @volumes = nil if @volumes == UNSET_VALUE end def validate(machine)