vagrant-digitalocean 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +10 -31
- data/lib/vagrant-digitalocean/actions/create.rb +4 -3
- data/lib/vagrant-digitalocean/actions/rebuild.rb +1 -1
- data/lib/vagrant-digitalocean/commands/list.rb +89 -0
- data/lib/vagrant-digitalocean/config.rb +4 -1
- data/lib/vagrant-digitalocean/plugin.rb +5 -0
- data/lib/vagrant-digitalocean/version.rb +1 -1
- data/locales/en.yml +5 -0
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MjUxMDgyZTdlNDg0MWQzMWQzZWIwYzJhY2ExNjcwNzk3MDQ3ZDJhNQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e7541cb9c846061aa891d33310cca80a8050157d
|
4
|
+
data.tar.gz: c804eb52850ffb127932dcb5337b35abd4edf500
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ODU1OGZlNzc1ZjQ2NWNmNmM5YTU5ZmY0MWMxZDI0NjllZDM4Y2JlNzJhMDU3
|
11
|
-
MGYzZDAxOWE0ZjFjMGI0MjE5ZjJiNWNhMjQxYmFmNDFkNmM2MmU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NjAxMzlkYzVlMDdiZGY2M2Y3ZDI2YzE2YTkzMDhjNmNmNzQ4ZTJmZDM3Yjll
|
14
|
-
Y2Q5YjE1YzVkNjQ2ZDg2OGFhMmYyNTYwOTc5MDZjNzY1YWU2MGI2MWE1ZTdl
|
15
|
-
M2E3OWNhOTNiYWRmMzQ5MGEyZDkzODNhMThiN2Q1ZTBjOTQzNzI=
|
6
|
+
metadata.gz: ec0c1de834854d1903f0cd97900729a0d36095c92d8bfb24508f4b107a0924f7b3382ed23a8247bc31c821ba29943a8ceb27d8643936c34a09d36ff429ac246d
|
7
|
+
data.tar.gz: 905bc72a941fb5d299d372dd42914894c462c4f66de51811c83577539b6f3cef98b9e4dad8a65ea204377972136cc27d10a9edcf84f5fa96a30e9ae9ee96f8ac
|
data/README.md
CHANGED
@@ -59,7 +59,7 @@ Vagrant.configure('2') do |config|
|
|
59
59
|
override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
|
60
60
|
|
61
61
|
provider.token = 'YOUR TOKEN'
|
62
|
-
provider.image = '
|
62
|
+
provider.image = 'ubuntu-14-04-x64'
|
63
63
|
provider.region = 'nyc2'
|
64
64
|
provider.size = '512mb'
|
65
65
|
end
|
@@ -77,14 +77,11 @@ Please note the following:
|
|
77
77
|
**Supported Configuration Attributes**
|
78
78
|
|
79
79
|
The following attributes are available to further configure the provider:
|
80
|
-
- `provider.image` - A string representing the image to use when creating a
|
81
|
-
|
82
|
-
|
83
|
-
It defaults to `Ubuntu 14.04 x64`.
|
84
|
-
- `provider.region` - A string representing the region to create the new
|
85
|
-
droplet in. It defaults to `nyc2`.
|
80
|
+
- `provider.image` - A string representing the image to use when creating a new droplet. It defaults to `ubuntu-14-04-x64`. List available images with the `digitalocean-list images` command.
|
81
|
+
- `provider.ipv6` - A boolean flag indicating whether to enable IPv6
|
82
|
+
- `provider.region` - A string representing the region to create the new droplet in. It defaults to `nyc2`. List available regions with the `digitalocean-list regions` command.
|
86
83
|
- `provider.size` - A string representing the size to use when creating a
|
87
|
-
new droplet (e.g. `1gb`). It defaults to `512mb`.
|
84
|
+
new droplet (e.g. `1gb`). It defaults to `512mb`. List available sizes with the `digitalocean-list sizes` command.
|
88
85
|
- `provider.private_networking` - A boolean flag indicating whether to enable
|
89
86
|
a private network interface (if the region supports private networking). It
|
90
87
|
defaults to `false`.
|
@@ -101,34 +98,16 @@ The provider will create a new user account with the specified SSH key for
|
|
101
98
|
authorization if `config.ssh.username` is set and the `provider.setup`
|
102
99
|
attribute is `true`.
|
103
100
|
|
104
|
-
###
|
101
|
+
### image, region and size slugs
|
105
102
|
|
106
|
-
|
107
|
-
Current Region-slug table is:
|
108
|
-
|
109
|
-
| slug | Region Name |
|
110
|
-
|:---- |:----------------|
|
111
|
-
| nyc1 | New York 1 |
|
112
|
-
| ams1 | Amsterdam 1 |
|
113
|
-
| sfo1 | San Francisco 1 |
|
114
|
-
| nyc2 | New York 2 |
|
115
|
-
| ams2 | Amsterdam 2 |
|
116
|
-
| sgp1 | Singapore 1 |
|
117
|
-
| lon1 | London 1 |
|
118
|
-
| nyc3 | New York 3 |
|
119
|
-
|
120
|
-
You can find latest region slug name using DigitalOcean API V2 call.
|
121
|
-
|
122
|
-
- example call.
|
103
|
+
Images, regions and sizes have to be specified with the slug name. You can find the slug names with the `digitalocean-list` commands:
|
123
104
|
|
124
105
|
```
|
125
|
-
|
126
|
-
|
127
|
-
|
106
|
+
vagrant digitalocean-list images $DIGITAL_OCEAN_TOKEN
|
107
|
+
vagrant digitalocean-list regions $DIGITAL_OCEAN_TOKEN
|
108
|
+
vagrant digitalocean-list sizes $DIGITAL_OCEAN_TOKEN
|
128
109
|
```
|
129
110
|
|
130
|
-
More detail: [DigitalOcean API - Regions](https://developers.digitalocean.com/#regions)
|
131
|
-
|
132
111
|
Run
|
133
112
|
---
|
134
113
|
After creating your project's `Vagrantfile` with the required configuration
|
@@ -19,7 +19,7 @@ module VagrantPlugins
|
|
19
19
|
|
20
20
|
image_id = @client
|
21
21
|
.request('/v2/images')
|
22
|
-
.find_id(:images, :
|
22
|
+
.find_id(:images, :slug => @machine.provider_config.image)
|
23
23
|
|
24
24
|
# submit new droplet request
|
25
25
|
result = @client.post('/v2/droplets', {
|
@@ -30,11 +30,12 @@ module VagrantPlugins
|
|
30
30
|
:ssh_keys => ssh_key_id,
|
31
31
|
:private_networking => @machine.provider_config.private_networking,
|
32
32
|
:backups => @machine.provider_config.backups_enabled,
|
33
|
-
:ipv6 => @machine.provider_config.ipv6
|
33
|
+
:ipv6 => @machine.provider_config.ipv6,
|
34
|
+
:user_data => @machine.provider_config.user_data
|
34
35
|
})
|
35
36
|
|
36
37
|
# wait for request to complete
|
37
|
-
env[:ui].info I18n.t('vagrant_digital_ocean.info.creating')
|
38
|
+
env[:ui].info I18n.t('vagrant_digital_ocean.info.creating')
|
38
39
|
@client.wait_for_event(env, result['links']['actions'].first['id'])
|
39
40
|
|
40
41
|
# assign the machine id for reference in other commands
|
@@ -18,7 +18,7 @@ module VagrantPlugins
|
|
18
18
|
# look up image id
|
19
19
|
image_id = @client
|
20
20
|
.request('/v2/images')
|
21
|
-
.find_id(:images, :
|
21
|
+
.find_id(:images, :slug => @machine.provider_config.image)
|
22
22
|
|
23
23
|
# submit rebuild request
|
24
24
|
result = @client.post("/v2/droplets/#{@machine.id}/actions", {
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'vagrant-digitalocean/helpers/client'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module DigitalOcean
|
6
|
+
module Commands
|
7
|
+
class List < Vagrant.plugin('2', :command)
|
8
|
+
def self.synopsis
|
9
|
+
"list available images and regions from Digital Ocean"
|
10
|
+
end
|
11
|
+
|
12
|
+
def execute
|
13
|
+
@token = nil
|
14
|
+
|
15
|
+
@opts = OptionParser.new do |o|
|
16
|
+
o.banner = 'Usage: vagrant digitalocean-list [options] <images|regions|sizes> <token>'
|
17
|
+
|
18
|
+
o.on("-r", "--[no-]regions", "show the regions when listing images") do |r|
|
19
|
+
@regions = r
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
argv = parse_options(@opts)
|
24
|
+
@token = argv[1]
|
25
|
+
|
26
|
+
if @token.nil?
|
27
|
+
usage
|
28
|
+
return 1
|
29
|
+
end
|
30
|
+
|
31
|
+
case argv[0]
|
32
|
+
when "images"
|
33
|
+
result = query('/v2/images')
|
34
|
+
images = Array(result["images"])
|
35
|
+
if @regions
|
36
|
+
images_table = images.map do |image|
|
37
|
+
'%-50s %-30s %-50s' % ["#{image['distribution']} #{image['name']}", image['slug'], image['regions'].join(', ')]
|
38
|
+
end
|
39
|
+
@env.ui.info I18n.t('vagrant_digital_ocean.info.images_with_regions', images: images_table.sort.join("\r\n"))
|
40
|
+
else
|
41
|
+
images_table = images.map do |image|
|
42
|
+
'%-50s %-30s' % ["#{image['distribution']} #{image['name']}", image['slug']]
|
43
|
+
end
|
44
|
+
@env.ui.info I18n.t('vagrant_digital_ocean.info.images', images: images_table.sort.join("\r\n"))
|
45
|
+
end
|
46
|
+
when "regions"
|
47
|
+
result = query('/v2/regions')
|
48
|
+
regions = Array(result["regions"])
|
49
|
+
regions_table = regions.map { |region| '%-30s %-12s' % [region['name'], region['slug']] }
|
50
|
+
@env.ui.info I18n.t('vagrant_digital_ocean.info.regions', regions: regions_table.sort.join("\r\n"))
|
51
|
+
when "sizes"
|
52
|
+
result = query('/v2/sizes')
|
53
|
+
sizes = Array(result["sizes"])
|
54
|
+
sizes_table = sizes.map { |size| '%-15s %-15s %-12s' % ["#{size['memory']}MB", size['vcpus'], size['slug']] }
|
55
|
+
@env.ui.info I18n.t('vagrant_digital_ocean.info.sizes', sizes: sizes_table.sort_by{|s| s['memory']}.join("\r\n"))
|
56
|
+
else
|
57
|
+
usage
|
58
|
+
return 1
|
59
|
+
end
|
60
|
+
|
61
|
+
0
|
62
|
+
rescue Faraday::Error::ConnectionFailed, RuntimeError => e
|
63
|
+
@env.ui.error I18n.t('vagrant_digital_ocean.info.list_error', message: e.message)
|
64
|
+
1
|
65
|
+
end
|
66
|
+
|
67
|
+
def query(path)
|
68
|
+
connection = Faraday.new({
|
69
|
+
:url => "https://api.digitalocean.com/"
|
70
|
+
})
|
71
|
+
|
72
|
+
result = connection.get(path, per_page: 100) do |req|
|
73
|
+
req.headers['Authorization'] = "Bearer #{@token}"
|
74
|
+
end
|
75
|
+
|
76
|
+
case result.status
|
77
|
+
when 200 then JSON.parse(result.body)
|
78
|
+
when 401 then raise("unauthorized access — is the token correct?")
|
79
|
+
else raise("call returned with status #{result.status}")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def usage
|
84
|
+
@env.ui.info(@opts)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -11,6 +11,7 @@ module VagrantPlugins
|
|
11
11
|
attr_accessor :ca_path
|
12
12
|
attr_accessor :ssh_key_name
|
13
13
|
attr_accessor :setup
|
14
|
+
attr_accessor :user_data
|
14
15
|
|
15
16
|
alias_method :setup?, :setup
|
16
17
|
|
@@ -25,11 +26,12 @@ module VagrantPlugins
|
|
25
26
|
@ca_path = UNSET_VALUE
|
26
27
|
@ssh_key_name = UNSET_VALUE
|
27
28
|
@setup = UNSET_VALUE
|
29
|
+
@user_data = UNSET_VALUE
|
28
30
|
end
|
29
31
|
|
30
32
|
def finalize!
|
31
33
|
@token = ENV['DO_TOKEN'] if @token == UNSET_VALUE
|
32
|
-
@image = '
|
34
|
+
@image = 'ubuntu-14-04-x64' if @image == UNSET_VALUE
|
33
35
|
@region = 'nyc2' if @region == UNSET_VALUE
|
34
36
|
@size = '512mb' if @size == UNSET_VALUE
|
35
37
|
@private_networking = false if @private_networking == UNSET_VALUE
|
@@ -38,6 +40,7 @@ module VagrantPlugins
|
|
38
40
|
@ca_path = nil if @ca_path == UNSET_VALUE
|
39
41
|
@ssh_key_name = 'Vagrant' if @ssh_key_name == UNSET_VALUE
|
40
42
|
@setup = true if @setup == UNSET_VALUE
|
43
|
+
@user_data = nil if @user_data == UNSET_VALUE
|
41
44
|
end
|
42
45
|
|
43
46
|
def validate(machine)
|
data/locales/en.yml
CHANGED
@@ -20,6 +20,11 @@ en:
|
|
20
20
|
trying_rsync_install: "Rsync not found, attempting to install with yum..."
|
21
21
|
rsyncing: "Rsyncing folder: %{hostpath} => %{guestpath}..."
|
22
22
|
rsync_missing: "The rsync executable was not found in the current path."
|
23
|
+
images: "Description Slug\n\n%{images}"
|
24
|
+
images_with_regions: "Description Slug Regions\n\n%{images}"
|
25
|
+
regions: "Description Slug\n\n%{regions}"
|
26
|
+
sizes: "Memory CPUs Slug\n\n%{sizes}"
|
27
|
+
list_error: 'Could not contact the Digital Ocean API: %{message}'
|
23
28
|
config:
|
24
29
|
token: "Token is required"
|
25
30
|
private_key: "SSH private key path is required"
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-digitalocean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bender
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.8.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.8.6
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: log4r
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Enables Vagrant to manage Digital Ocean droplets
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/vagrant-digitalocean/actions/setup_sudo.rb
|
82
82
|
- lib/vagrant-digitalocean/actions/setup_user.rb
|
83
83
|
- lib/vagrant-digitalocean/actions/sync_folders.rb
|
84
|
+
- lib/vagrant-digitalocean/commands/list.rb
|
84
85
|
- lib/vagrant-digitalocean/commands/rebuild.rb
|
85
86
|
- lib/vagrant-digitalocean/config.rb
|
86
87
|
- lib/vagrant-digitalocean/errors.rb
|
@@ -106,17 +107,17 @@ require_paths:
|
|
106
107
|
- lib
|
107
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
109
|
requirements:
|
109
|
-
- -
|
110
|
+
- - '>='
|
110
111
|
- !ruby/object:Gem::Version
|
111
112
|
version: '0'
|
112
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
114
|
requirements:
|
114
|
-
- -
|
115
|
+
- - '>='
|
115
116
|
- !ruby/object:Gem::Version
|
116
117
|
version: '0'
|
117
118
|
requirements: []
|
118
119
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.0.14
|
120
121
|
signing_key:
|
121
122
|
specification_version: 4
|
122
123
|
summary: Enables Vagrant to manage Digital Ocean droplets
|