vagrant-flow 1.0.19 → 1.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/lib/vagrant-flow/command/digitalocean_api.rb +34 -15
- data/lib/vagrant-flow/command/hostfile.rb +4 -4
- data/lib/vagrant-flow/templates/multiinit.erb +11 -10
- data/lib/vagrant-flow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00d213603722e753a64dc6d017f1a3411deffef2
|
4
|
+
data.tar.gz: 8b4f6e26f222c8fe0e508ec771889bb33ffabe53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e6232bbd26f61b63b1fc22848ab2e52bc3b8be29404962affee91464075e683ef08f28699c03b07c4af43a05faf01b270a2c41805c7122bb49ae68f14c36998
|
7
|
+
data.tar.gz: 2d552ee70774fee88632a1f177cad5eb811661dd8041339a064a67a71d4095f4c6bd41e6238b2e1b9a1b22ea6935b880705b41494f5aedf69cee8eb24431e35c
|
data/README.md
CHANGED
@@ -15,6 +15,7 @@ Vagrant-Flow is a [vagrant] (http://www.vagrantup.com/) plugin which allows for
|
|
15
15
|
echo "StrictHostKeyChecking no" >> ~/.ssh/config
|
16
16
|
|
17
17
|
#If you're on OSX
|
18
|
+
#This step may no longer be necessary as vagrant-digitalocean shouldn't require it anymore
|
18
19
|
brew install curl-ca-bundle
|
19
20
|
|
20
21
|
|
@@ -141,17 +142,18 @@ machines:
|
|
141
142
|
|
142
143
|
```
|
143
144
|
|
144
|
-
Example multiinitconfig.yml file for use with virtualbox and digitalocean providers. All the extra parameters are required to make digitalocean work.
|
145
|
+
Example multiinitconfig.yml file for use with virtualbox and digitalocean providers. All the extra parameters are required to make digitalocean work. Get your digitalOcean token by logging in and generating a new token under "Apps & API"
|
145
146
|
```
|
146
147
|
---
|
147
148
|
#Where your ssh private key lives (for use with digital ocean)
|
148
149
|
#~/.ssh/id_rsa is the default, so you can omit this value if you want
|
149
150
|
:sshPrivateKeyPath: ~/.ssh/id_rsa
|
150
151
|
|
151
|
-
|
152
|
-
#
|
153
|
-
|
154
|
-
:
|
152
|
+
|
153
|
+
#The digitalOceanToken must be set for digitalocean to work. You can generate one at https://cloud.digitalocean.com/settings/applications
|
154
|
+
#Omit it if you don't want digitalocean as a provider option in your vagrantfile
|
155
|
+
:digitalOceanToken: xxxxxxxxxxxxxxyyyyyyyzzzzz988765445678765
|
156
|
+
|
155
157
|
|
156
158
|
:intnetName: neverwinterDP
|
157
159
|
machines:
|
@@ -1,41 +1,60 @@
|
|
1
1
|
require "net/http"
|
2
2
|
require "uri"
|
3
3
|
require "json"
|
4
|
-
require "uri"
|
5
4
|
|
6
5
|
class DigitalOcean_Api
|
7
6
|
|
8
|
-
def initialize(digitaloceanurl= 'https://api.digitalocean.com/droplets
|
7
|
+
def initialize(digitaloceanurl= 'https://api.digitalocean.com', digitaloceanpath="/v2/droplets")
|
9
8
|
@DIGITALOCEAN_URL=digitaloceanurl
|
9
|
+
@DIGITALOCEAN_PATH=digitaloceanpath
|
10
10
|
end
|
11
11
|
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
#params should be a hash that will be in the form of
|
13
|
+
#{"Authorization"=>"Bearer ~~DIGITALOCEANTOKEN~~"}
|
14
|
+
def makeApiCall(params)
|
15
|
+
|
16
|
+
uri = URI.parse(@DIGITALOCEAN_URL)
|
17
|
+
http = Net::HTTP.new(uri.host,uri.port)
|
18
|
+
http.use_ssl = true
|
19
|
+
request = Net::HTTP::Get.new(@DIGITALOCEAN_PATH)
|
20
|
+
|
21
|
+
request.initialize_http_header(params)
|
22
|
+
response = http.request(request)
|
18
23
|
return JSON.parse(response.body)
|
19
24
|
end
|
20
25
|
|
21
|
-
|
26
|
+
|
22
27
|
#returns parsed hash object from returned json
|
23
|
-
def showAllActiveDroplets(
|
28
|
+
def showAllActiveDroplets(token)
|
24
29
|
x = {
|
25
|
-
"
|
26
|
-
"api_key" => apiKey,
|
30
|
+
"Authorization" => "Bearer "+token
|
27
31
|
}
|
28
32
|
return makeApiCall(x)
|
29
33
|
end
|
30
34
|
|
31
35
|
#Calls showAllActiveDroplets and then parses the info for just hostname and ip
|
32
|
-
def getHostNamesAndIps(
|
33
|
-
hash = showAllActiveDroplets(
|
36
|
+
def getHostNamesAndIps(token)
|
37
|
+
hash = showAllActiveDroplets(token)
|
34
38
|
returnHash = []
|
39
|
+
|
35
40
|
hash["droplets"].each {|droplet|
|
41
|
+
#Grab the IP information for each droplet
|
42
|
+
#Each IP is contained in an array, so extract that
|
43
|
+
ip = []
|
44
|
+
droplet["networks"]["v4"].each do |x|
|
45
|
+
ip.push(x["ip_address"])
|
46
|
+
end
|
47
|
+
|
48
|
+
#Usually there's only the one IP address per machine,
|
49
|
+
#this will help with backwards compatibility
|
50
|
+
if ip.length == 1
|
51
|
+
ip = ip[0]
|
52
|
+
end
|
53
|
+
|
54
|
+
|
36
55
|
returnHash.push({
|
37
56
|
:hostname => droplet["name"],
|
38
|
-
:ip =>
|
57
|
+
:ip => ip
|
39
58
|
})
|
40
59
|
}
|
41
60
|
return returnHash
|
@@ -30,7 +30,7 @@ module VagrantPlugins
|
|
30
30
|
options[:nowrite] = false
|
31
31
|
options[:quiet] = false
|
32
32
|
options[:digitalocean] = false
|
33
|
-
options[:digitalocean_file] = "
|
33
|
+
options[:digitalocean_file] = "multiinitconfig.yml"
|
34
34
|
|
35
35
|
#Parse option, look up OptionParser documentation
|
36
36
|
opts = OptionParser.new do |o|
|
@@ -48,11 +48,11 @@ module VagrantPlugins
|
|
48
48
|
options[:nowrite] = true
|
49
49
|
end
|
50
50
|
|
51
|
-
o.on("-d", "--digitalocean", "(Optional) Writes your digital ocean's hostnames and IP addresses to
|
51
|
+
o.on("-d", "--digitalocean", "(Optional) Writes your digital ocean's hostnames and IP addresses to the host files of your machines. Default file is multiinitconfig.yml") do |f|
|
52
52
|
options[:digitalocean] = true
|
53
53
|
end
|
54
54
|
|
55
|
-
o.on("-o", "--digitaloceanfile FILE", "(Optional) File to read in for -d option instead of
|
55
|
+
o.on("-o", "--digitaloceanfile FILE", "(Optional) File to read in for -d option instead of multiinitconfig.yml") do |f|
|
56
56
|
options[:digitalocean_file] = f
|
57
57
|
end
|
58
58
|
end
|
@@ -67,7 +67,7 @@ module VagrantPlugins
|
|
67
67
|
if options[:digitalocean]
|
68
68
|
config = YAML.load_file(options[:digitalocean_file])
|
69
69
|
digitalocean = DigitalOcean_Api.new()
|
70
|
-
hostinfo = digitalocean.getHostNamesAndIps(config[:
|
70
|
+
hostinfo = digitalocean.getHostNamesAndIps(config[:digitalOceanToken])
|
71
71
|
else
|
72
72
|
with_target_vms(argv, :provider => options[:provider]) do |machine|
|
73
73
|
return unless machine.communicate.ready?
|
@@ -8,7 +8,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
8
8
|
|
9
9
|
Vagrant.require_version ">= 1.4.3"
|
10
10
|
|
11
|
-
|
11
|
+
<% if @sshPrivateKeyPath %>
|
12
|
+
config.ssh.private_key_path = '<%= @sshPrivateKeyPath %>'
|
13
|
+
<% end %>
|
12
14
|
|
13
15
|
<% for machine in @machines %>
|
14
16
|
|
@@ -21,22 +23,21 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
21
23
|
<%= machine["name"]%>.vm.network :private_network, ip: "<%= machine["ip"]%>", virtualbox__intnet: "<%= @intnetName %>"
|
22
24
|
<%= machine["name"]%>.vm.hostname = "<%= machine["name"]%>"
|
23
25
|
|
24
|
-
<% if machine.has_key?("digitalOceanImage") and machine.has_key?("digitalOceanRegion") and @digitalOceanApiKey and @digitalOceanClientId and @sshPrivateKeyPath %>
|
25
|
-
#digitalOcean provider
|
26
26
|
<%= machine["name"]%>.vm.synced_folder ".", "/vagrant", disabled: true
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
|
28
|
+
<% if machine.has_key?("digitalOceanImage") and machine.has_key?("digitalOceanRegion") and @digitalOceanToken and @sshPrivateKeyPath %>
|
29
|
+
#digitalOcean provider
|
30
|
+
<%= machine["name"]%>.vm.provider :digital_ocean do |provider, override|
|
31
|
+
provider.token = '<%= @digitalOceanToken %>'
|
31
32
|
provider.region = '<%=machine["digitalOceanRegion"] %>'
|
32
|
-
provider.image
|
33
|
-
provider.size
|
33
|
+
provider.image = '<%= machine["digitalOceanImage"] %>'
|
34
|
+
provider.size = '<%= machine["ram"] %>'
|
34
35
|
end
|
35
36
|
<% end %>
|
36
37
|
|
37
38
|
<% if machine.has_key?("name") and machine.has_key?("url") %>
|
38
39
|
#VirtualBox provider
|
39
|
-
|
40
|
+
<%= machine["name"]%>.vm.provider :virtualbox do |vb|
|
40
41
|
vb.name = "<%= machine["name"]%>"
|
41
42
|
vb.customize ["modifyvm", :id, "--memory", "<%= machine["vagrantram"] %>"]
|
42
43
|
# vb.customize ["modifyvm", :id, "--cpus", "2"]
|
data/lib/vagrant-flow/version.rb
CHANGED