zergrush_vagrant 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/COPYING +1 -0
- data/LICENSE +1 -0
- data/README.md +17 -0
- data/Rakefile +1 -0
- data/lib/zergrush_vagrant/erbalize.rb +35 -0
- data/lib/zergrush_vagrant/init.rb +167 -0
- data/lib/zergrush_vagrant/renderer.rb +176 -0
- data/lib/zergrush_vagrant/version.rb +26 -0
- data/resources/bridging.template +1 -0
- data/resources/defaults.yaml +2 -0
- data/resources/hostonly.template +1 -0
- data/resources/machine.template +22 -0
- data/resources/main.template +11 -0
- data/resources/provider.template +3 -0
- data/resources/tasks_schema.template +174 -0
- data/zergrush_vagrant.gemspec +32 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9dd98a5c71a254b0c02f3826f144f510891feada
|
4
|
+
data.tar.gz: facd3cf108c86b6ca007812562f7ebe86e99fdd8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0049d7c9350f748c4065418a52be9a81f27f26935ef57d4eeef13a46b49e3c554f82e1dc8e0de2ae1a0a577997db5f7651376b1080cca8825559cc3a438a317b
|
7
|
+
data.tar.gz: 113adfdbfd8c0873f1c6b6e9e75ec638d9d3e624ba2d58ebe00a3970ef5c791a85114914e0fa3b8a867d01ab860b706e86bdb21dbfa3536c21c1cf46042a785e
|
data/.gitignore
ADDED
data/COPYING
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
No copying restrictions/license given.
|
data/LICENSE
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
No license given.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
zergrush_vagrant GemPlugin
|
2
|
+
===
|
3
|
+
|
4
|
+
Tasks
|
5
|
+
--------------
|
6
|
+
- type - Type of task payload. 'shell', 'chef_client' or 'chef_solo'
|
7
|
+
- shell task parameters:
|
8
|
+
- [shell provisioner]
|
9
|
+
- chef_client and chef_solo task parameters map directly to Vagrant provisioner docs, **EXCEPT the node_name parameter**:
|
10
|
+
- [chef_solo provisioner]
|
11
|
+
- [chef_client provisioner]
|
12
|
+
- [chef common options]
|
13
|
+
|
14
|
+
[chef_solo provisioner]:http://docs.vagrantup.com/v2/provisioning/chef_solo.html
|
15
|
+
[chef_client provisioner]:https://docs.vagrantup.com/v2/provisioning/chef_client.html
|
16
|
+
[chef common options]:http://docs.vagrantup.com/v2/provisioning/chef_common.html
|
17
|
+
[shell provisioner]:http://docs.vagrantup.com/v2/provisioning/shell.html
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#--
|
2
|
+
|
3
|
+
# Copyright 2014 by MTN Sattelite Communications
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to
|
7
|
+
# deal in the Software without restriction, including without limitation the
|
8
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
9
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
21
|
+
# IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require 'erb'
|
25
|
+
require 'ostruct'
|
26
|
+
|
27
|
+
class Erbalize < OpenStruct
|
28
|
+
def self.erbalize_hash(template, sources)
|
29
|
+
Erbalize.new(sources).render(template)
|
30
|
+
end
|
31
|
+
|
32
|
+
def render(template)
|
33
|
+
ERB.new(template, nil, '-').result(binding)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
#--
|
2
|
+
|
3
|
+
# Copyright 2014 by MTN Sattelite Communications
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to
|
7
|
+
# deal in the Software without restriction, including without limitation the
|
8
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
9
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
21
|
+
# IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require 'zerg'
|
25
|
+
require_relative 'renderer'
|
26
|
+
|
27
|
+
# give this class the name you want for your command zergrush_vagrant
|
28
|
+
class Vagrant < ZergGemPlugin::Plugin "/driver"
|
29
|
+
def rush hive_location, task_name, task_hash, debug
|
30
|
+
abort("ERROR: Vagrant not installed!") unless which("vagrant") != nil
|
31
|
+
puts ("Will perform task #{task_name} with contents:\n #{task_hash.ai}")
|
32
|
+
|
33
|
+
renderer = Renderer.new(
|
34
|
+
hive_location,
|
35
|
+
task_name,
|
36
|
+
task_hash)
|
37
|
+
renderer.render
|
38
|
+
|
39
|
+
debug_string = (debug == true) ? " --debug" : ""
|
40
|
+
|
41
|
+
# bring up all of the VMs first.
|
42
|
+
puts("Starting vagrant in #{File.join("#{hive_location}", "driver", task_hash["vm"]["driver"]["drivertype"], task_name)}")
|
43
|
+
for index in 0..task_hash["instances"] - 1
|
44
|
+
create_pid = Process.spawn(
|
45
|
+
{
|
46
|
+
"VAGRANT_CWD" => File.join("#{hive_location}", "driver", task_hash["vm"]["driver"]["drivertype"], task_name),
|
47
|
+
"VAGRANT_DEFAULT_PROVIDER" => task_hash["vm"]["driver"]["providertype"]
|
48
|
+
},
|
49
|
+
"vagrant up zergling_#{index} --no-provision#{debug_string}")
|
50
|
+
Process.wait(create_pid)
|
51
|
+
|
52
|
+
if $?.exitstatus != 0
|
53
|
+
puts "Vagrant failed while creating one of the VMs. Will clean task #{task_name}:"
|
54
|
+
clean(hive_location, task_name, task_hash, debug)
|
55
|
+
abort("ERROR: vagrant failed!")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
puts("Running tasks in vagrant virtual machines...")
|
60
|
+
# and provision them all at once (sort of)
|
61
|
+
provisioners = Array.new
|
62
|
+
provision_pid = nil
|
63
|
+
for index in 0..task_hash["instances"] - 1
|
64
|
+
provision_pid = Process.spawn(
|
65
|
+
{
|
66
|
+
"VAGRANT_CWD" => File.join("#{hive_location}", "driver", task_hash["vm"]["driver"]["drivertype"], task_name),
|
67
|
+
"VAGRANT_DEFAULT_PROVIDER" => task_hash["vm"]["driver"]["providertype"]
|
68
|
+
},
|
69
|
+
"vagrant provision zergling_#{index}#{debug_string}")
|
70
|
+
provisioners.push({:name => "zergling_#{index}", :pid => provision_pid})
|
71
|
+
end
|
72
|
+
|
73
|
+
# wait for everything to finish...
|
74
|
+
errors = Array.new
|
75
|
+
lock = Mutex.new
|
76
|
+
provisioners.each { |provisioner|
|
77
|
+
Thread.new {
|
78
|
+
Process.wait(provisioner[:pid]);
|
79
|
+
lock.synchronize do
|
80
|
+
errors.push(provisioner[:name]) unless $?.exitstatus == 0
|
81
|
+
end
|
82
|
+
}.join
|
83
|
+
}
|
84
|
+
|
85
|
+
if task_hash["vm"]["keepalive"] == false
|
86
|
+
halt(hive_location, task_name, task_hash, debug)
|
87
|
+
else
|
88
|
+
puts "Will leave instances running."
|
89
|
+
end
|
90
|
+
|
91
|
+
abort("ERROR: Finished with errors in: #{errors.to_s}") unless errors.length == 0
|
92
|
+
end
|
93
|
+
|
94
|
+
def clean hive_location, task_name, task_hash, debug
|
95
|
+
abort("ERROR: Vagrant not installed!") unless which("vagrant") != nil
|
96
|
+
puts("Cleaning task #{task_name} ...")
|
97
|
+
|
98
|
+
renderer = Renderer.new(
|
99
|
+
hive_location,
|
100
|
+
task_name,
|
101
|
+
task_hash)
|
102
|
+
renderer.render
|
103
|
+
|
104
|
+
# run vagrant cleanup
|
105
|
+
debug_string = (debug == true) ? " --debug" : ""
|
106
|
+
|
107
|
+
for index in 0..task_hash["instances"] - 1
|
108
|
+
cleanup_pid = Process.spawn(
|
109
|
+
{
|
110
|
+
"VAGRANT_CWD" => File.join("#{hive_location}", "driver", task_hash["vm"]["driver"]["drivertype"], task_name),
|
111
|
+
"VAGRANT_DEFAULT_PROVIDER" => task_hash["vm"]["driver"]["providertype"]
|
112
|
+
},
|
113
|
+
"vagrant destroy zergling_#{index} --force#{debug_string}")
|
114
|
+
Process.wait(cleanup_pid)
|
115
|
+
abort("ERROR: vagrant failed!") unless $?.exitstatus == 0
|
116
|
+
end
|
117
|
+
|
118
|
+
cleanup_pid = Process.spawn(
|
119
|
+
{
|
120
|
+
"VAGRANT_CWD" => File.join("#{hive_location}", "driver", task_hash["vm"]["driver"]["drivertype"], task_name)
|
121
|
+
},
|
122
|
+
"vagrant box remove zergling_#{task_name}_#{task_hash["vm"]["driver"]["providertype"]}#{debug_string} #{task_hash["vm"]["driver"]["providertype"]}")
|
123
|
+
Process.wait(cleanup_pid)
|
124
|
+
end
|
125
|
+
|
126
|
+
def halt hive_location, task_name, task_hash, debug
|
127
|
+
abort("ERROR: Vagrant not installed!") unless which("vagrant") != nil
|
128
|
+
puts("Halting all vagrant virtual machines for task #{task_name} ...")
|
129
|
+
|
130
|
+
renderer = Renderer.new(
|
131
|
+
hive_location,
|
132
|
+
task_name,
|
133
|
+
task_hash)
|
134
|
+
renderer.render
|
135
|
+
|
136
|
+
debug_string = (debug == true) ? " --debug" : ""
|
137
|
+
|
138
|
+
# halt all machines
|
139
|
+
halt_pid = nil
|
140
|
+
for index in 0..task_hash["instances"] - 1
|
141
|
+
halt_pid = Process.spawn(
|
142
|
+
{
|
143
|
+
"VAGRANT_CWD" => File.join("#{hive_location}", "driver", task_hash["vm"]["driver"]["drivertype"], task_name),
|
144
|
+
"VAGRANT_DEFAULT_PROVIDER" => task_hash["vm"]["driver"]["providertype"]
|
145
|
+
},
|
146
|
+
"vagrant halt zergling_#{index}#{debug_string}")
|
147
|
+
Process.wait(halt_pid)
|
148
|
+
abort("ERROR: vagrant halt failed on machine zergling_#{index}!") unless $?.exitstatus == 0
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def task_schema
|
153
|
+
return File.open(File.join("#{File.dirname(__FILE__)}", "..", "..", "resources", "tasks_schema.template"), 'r').read
|
154
|
+
end
|
155
|
+
|
156
|
+
def which(cmd)
|
157
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
158
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
159
|
+
exts.each { |ext|
|
160
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
161
|
+
return exe if File.executable? exe
|
162
|
+
}
|
163
|
+
end
|
164
|
+
return nil
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
@@ -0,0 +1,176 @@
|
|
1
|
+
#--
|
2
|
+
|
3
|
+
# Copyright 2014 by MTN Sattelite Communications
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to
|
7
|
+
# deal in the Software without restriction, including without limitation the
|
8
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
9
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
21
|
+
# IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require 'awesome_print'
|
25
|
+
require 'fileutils'
|
26
|
+
require 'securerandom'
|
27
|
+
require_relative 'erbalize'
|
28
|
+
|
29
|
+
class Renderer
|
30
|
+
|
31
|
+
# generate a virtualbox - compatible MAC address
|
32
|
+
def generateMACAddress()
|
33
|
+
firstChar = (0..255).map(&:chr).select{|x| x =~ /[0-9A-Fa-f]/}.sample(1).join
|
34
|
+
secondChar = (0..255).map(&:chr).select{|x| x =~ /[02468ACEace]/}.sample(1).join
|
35
|
+
restOfChars = (0..255).map(&:chr).select{|x| x =~ /[0-9A-Fa-f]/}.sample(10).join
|
36
|
+
return "#{firstChar}#{secondChar}#{restOfChars}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(hive_location, task_name, task_hash)
|
40
|
+
@vm = task_hash["vm"]
|
41
|
+
@name = task_name
|
42
|
+
@instances = task_hash["instances"]
|
43
|
+
@tasks = task_hash["tasks"]
|
44
|
+
@synced_folders = task_hash["synced_folders"]
|
45
|
+
@hive_location = hive_location
|
46
|
+
end
|
47
|
+
|
48
|
+
def render
|
49
|
+
puts ("Rendering driver templates...")
|
50
|
+
|
51
|
+
# load the template files
|
52
|
+
main_template = File.open(File.join("#{File.dirname(__FILE__)}", "..", "..", "resources", "main.template"), 'r').read
|
53
|
+
|
54
|
+
# load the provider top level template
|
55
|
+
provider_parent_template = File.open(File.join("#{File.dirname(__FILE__)}", "..", "..", "resources", "provider.template"), 'r').read
|
56
|
+
|
57
|
+
# load the machine details template
|
58
|
+
machine_template = File.open(File.join("#{File.dirname(__FILE__)}", "..", "..", "resources", "machine.template"), 'r').read
|
59
|
+
|
60
|
+
# load the bridge details template
|
61
|
+
bridge_template = File.open(File.join("#{File.dirname(__FILE__)}", "..", "..", "resources", "bridging.template"), 'r').read
|
62
|
+
|
63
|
+
# load the host only network details template
|
64
|
+
hostonly_template = File.open(File.join("#{File.dirname(__FILE__)}", "..", "..", "resources", "hostonly.template"), 'r').read
|
65
|
+
|
66
|
+
# render templates....
|
67
|
+
# render provider details to string
|
68
|
+
#
|
69
|
+
# render provider details into a string
|
70
|
+
provider_details_array = @vm["driver"]["provider_options"]
|
71
|
+
provider_details = ""
|
72
|
+
for index in 0..provider_details_array.length - 1
|
73
|
+
provider_details += "\t\t" + provider_details_array[index] + "\n"
|
74
|
+
end
|
75
|
+
|
76
|
+
# render provider parent
|
77
|
+
sources = {
|
78
|
+
:provider => @vm["driver"]["providertype"],
|
79
|
+
:provider_specifics => provider_details
|
80
|
+
}
|
81
|
+
provider_parent_string = Erbalize.erbalize_hash(provider_parent_template, sources)
|
82
|
+
|
83
|
+
# render machine template
|
84
|
+
all_macs = Array.new
|
85
|
+
all_machines = ""
|
86
|
+
for index in 0..@instances - 1
|
87
|
+
|
88
|
+
# last ip octet offset for host only networking
|
89
|
+
ip_octet_offset = index
|
90
|
+
|
91
|
+
# inject randomized node_name into chef_client tasks
|
92
|
+
@tasks.each { |task|
|
93
|
+
if task["type"] == "chef_client"
|
94
|
+
task["node_name"] = "zergling_#{index}_#{SecureRandom.hex(20)}"
|
95
|
+
end
|
96
|
+
}
|
97
|
+
|
98
|
+
# tasks array rendered to ruby string. double encoding to escape quotes and allow for variable expansion
|
99
|
+
tasks_array = @tasks.to_json.to_json
|
100
|
+
|
101
|
+
# do we need the bridging template as well?
|
102
|
+
bridge_section = nil
|
103
|
+
if @vm.has_key?("bridge_description")
|
104
|
+
# mac address to use?
|
105
|
+
new_mac = ""
|
106
|
+
begin
|
107
|
+
new_mac = generateMACAddress()
|
108
|
+
end while all_macs.include? new_mac
|
109
|
+
|
110
|
+
sources = {
|
111
|
+
:machine_mac => new_mac,
|
112
|
+
:bridged_eth_description => @vm["bridge_description"]
|
113
|
+
}
|
114
|
+
bridge_section = Erbalize.erbalize_hash(bridge_template, sources)
|
115
|
+
end
|
116
|
+
|
117
|
+
# do we need the host only template as well?
|
118
|
+
hostonly_section = nil
|
119
|
+
if @vm["private_network"] == true
|
120
|
+
sources = {
|
121
|
+
:machine_name => "zergling_#{index}",
|
122
|
+
:last_octet => ip_octet_offset + 4, # TODO: this is probably specific to virtualbox networking
|
123
|
+
}
|
124
|
+
hostonly_section = Erbalize.erbalize_hash(hostonly_template, sources)
|
125
|
+
end
|
126
|
+
|
127
|
+
# synced folders
|
128
|
+
folder_definitions = nil
|
129
|
+
if @synced_folders != nil
|
130
|
+
folder_definitions = ""
|
131
|
+
@synced_folders.each { |folder|
|
132
|
+
other_options = ""
|
133
|
+
if folder.has_key?("options")
|
134
|
+
folder["options"].each { |option|
|
135
|
+
option.each do |key, value|
|
136
|
+
if value.is_a?(String)
|
137
|
+
other_options += ", :#{key} => \"#{value}\""
|
138
|
+
else
|
139
|
+
other_options += ", :#{key} => #{value}"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
}
|
143
|
+
end
|
144
|
+
|
145
|
+
folder_definition = "zergling_#{index}.vm.synced_folder \"#{folder['host_path']}\", \"#{folder['guest_path']}\""
|
146
|
+
folder_definition = "#{folder_definition}#{other_options}" unless other_options.empty?()
|
147
|
+
folder_definitions += "\t\t#{folder_definition}\n"
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
sources = {
|
152
|
+
:machine_name => "zergling_#{index}",
|
153
|
+
:bridge_specifics => bridge_section,
|
154
|
+
:hostonly_specifics => hostonly_section,
|
155
|
+
:tasks_array => tasks_array,
|
156
|
+
:sync_folders_array => folder_definitions
|
157
|
+
}.delete_if { |k, v| v.nil? }
|
158
|
+
|
159
|
+
machine_section = Erbalize.erbalize_hash(machine_template, sources)
|
160
|
+
all_machines += "\n#{machine_section}"
|
161
|
+
end
|
162
|
+
|
163
|
+
sources = {
|
164
|
+
:provider_section => provider_parent_string,
|
165
|
+
:basebox_path => @vm["basebox"],
|
166
|
+
:box_name => "zergling_#{@name}_#{@vm["driver"]["providertype"]}",
|
167
|
+
:vm_defines => all_machines
|
168
|
+
}
|
169
|
+
full_template = Erbalize.erbalize_hash(main_template, sources)
|
170
|
+
|
171
|
+
# write the file
|
172
|
+
puts ("Writing #{File.join("#{@hive_location}", "driver", @vm["driver"]["drivertype"], @name, "Vagrantfile")}...")
|
173
|
+
FileUtils.mkdir_p(File.join("#{@hive_location}", "driver", @vm["driver"]["drivertype"], @name))
|
174
|
+
File.open(File.join("#{@hive_location}", "driver", @vm["driver"]["drivertype"], @name, "Vagrantfile"), 'w') { |file| file.write(full_template) }
|
175
|
+
end
|
176
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#--
|
2
|
+
|
3
|
+
# Copyright 2014 by MTN Sattelite Communications
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to
|
7
|
+
# deal in the Software without restriction, including without limitation the
|
8
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
9
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
21
|
+
# IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module ZergrushVagrant
|
25
|
+
VERSION = "0.0.1"
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= machine_name %>.vm.network :public_network, :bridge => "<%= bridged_eth_description %>", :mac => <%= machine_mac %>, :use_dhcp_assigned_default_route => true
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= machine_name %>.vm.network :private_network, ip: "192.168.50.<%= last_octet %>"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# define the machine name
|
2
|
+
config.vm.define "<%= machine_name %>" do |<%= machine_name %>|
|
3
|
+
<%= bridge_specifics -%>
|
4
|
+
<%= hostonly_specifics %>
|
5
|
+
<%= sync_folders_array -%>
|
6
|
+
|
7
|
+
# provisioning
|
8
|
+
tasks = JSON.parse(<%= tasks_array %>)
|
9
|
+
tasks.each { |task|
|
10
|
+
if task["type"] == "chef_client" || task["type"] == "chef_solo"
|
11
|
+
<%= machine_name %>.omnibus.chef_version = :latest
|
12
|
+
end
|
13
|
+
|
14
|
+
<%= machine_name %>.vm.provision "#{task["type"]}" do |provisioner|
|
15
|
+
task.each do |key, value|
|
16
|
+
next if key == "type"
|
17
|
+
provisioner.send("#{key}=", value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Vagrant.configure(2) do |config|
|
2
|
+
<%= provider_section %>
|
3
|
+
|
4
|
+
config.vagrant.host = :detect
|
5
|
+
config.vm.box_url = "<%= basebox_path %>"
|
6
|
+
config.vm.box = "<%= box_name %>"
|
7
|
+
config.vm.boot_timeout = 300
|
8
|
+
config.vm.graceful_halt_timeout = 60
|
9
|
+
<%= vm_defines -%>
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
"properties": {
|
2
|
+
"type": {
|
3
|
+
"type": "string",
|
4
|
+
"pattern": "^(shell|chef_client|chef_solo)$"
|
5
|
+
},
|
6
|
+
"inline": {
|
7
|
+
"type": "string"
|
8
|
+
},
|
9
|
+
"path": {
|
10
|
+
"type": "string"
|
11
|
+
},
|
12
|
+
"parameters": {
|
13
|
+
"type": "string"
|
14
|
+
},
|
15
|
+
"environment": {
|
16
|
+
"type": "string"
|
17
|
+
},
|
18
|
+
"upload_path": {
|
19
|
+
"type": "string"
|
20
|
+
},
|
21
|
+
"recipe_url": {
|
22
|
+
"type": "string"
|
23
|
+
},
|
24
|
+
"client_key_path": {
|
25
|
+
"type": "string"
|
26
|
+
},
|
27
|
+
"validation_client_name": {
|
28
|
+
"type": "string"
|
29
|
+
},
|
30
|
+
"arguments": {
|
31
|
+
"type": "string"
|
32
|
+
},
|
33
|
+
"chef_server_url": {
|
34
|
+
"type": "string"
|
35
|
+
},
|
36
|
+
"validation_key_path": {
|
37
|
+
"type": "string"
|
38
|
+
},
|
39
|
+
"encrypted_data_bag_secret_key_path": {
|
40
|
+
"type": "string"
|
41
|
+
},
|
42
|
+
"binary_path": {
|
43
|
+
"type": "string"
|
44
|
+
},
|
45
|
+
"custom_config_path": {
|
46
|
+
"type": "string"
|
47
|
+
},
|
48
|
+
"formatter": {
|
49
|
+
"type": "string"
|
50
|
+
},
|
51
|
+
"http_proxy": {
|
52
|
+
"type": "string"
|
53
|
+
},
|
54
|
+
"http_proxy_user": {
|
55
|
+
"type": "string"
|
56
|
+
},
|
57
|
+
"http_proxy_pass": {
|
58
|
+
"type": "string"
|
59
|
+
},
|
60
|
+
"no_proxy": {
|
61
|
+
"type": "string"
|
62
|
+
},
|
63
|
+
"https_proxy": {
|
64
|
+
"type": "string"
|
65
|
+
},
|
66
|
+
"https_proxy_user": {
|
67
|
+
"type": "string"
|
68
|
+
},
|
69
|
+
"https_proxy_pass": {
|
70
|
+
"type": "string"
|
71
|
+
},
|
72
|
+
"log_level": {
|
73
|
+
"type": "string"
|
74
|
+
},
|
75
|
+
"provisioning_path": {
|
76
|
+
"type": "string"
|
77
|
+
},
|
78
|
+
"file_cache_path": {
|
79
|
+
"type": "string"
|
80
|
+
},
|
81
|
+
"file_backup_path": {
|
82
|
+
"type": "string"
|
83
|
+
},
|
84
|
+
"verbose_logging": {
|
85
|
+
"type": "boolean"
|
86
|
+
},
|
87
|
+
"delete_node": {
|
88
|
+
"type": "boolean"
|
89
|
+
},
|
90
|
+
"delete_client": {
|
91
|
+
"type": "boolean"
|
92
|
+
},
|
93
|
+
"nfs": {
|
94
|
+
"type": "boolean"
|
95
|
+
},
|
96
|
+
"binary": {
|
97
|
+
"type": "boolean"
|
98
|
+
},
|
99
|
+
"keep_color": {
|
100
|
+
"type": "boolean"
|
101
|
+
},
|
102
|
+
"priveleged": {
|
103
|
+
"type": "boolean"
|
104
|
+
},
|
105
|
+
"attempts": {
|
106
|
+
"type": "integer"
|
107
|
+
},
|
108
|
+
"json": {
|
109
|
+
"type": "object"
|
110
|
+
},
|
111
|
+
"cookbooks_path": {
|
112
|
+
"type": "array",
|
113
|
+
"minItems": 1,
|
114
|
+
"items": [
|
115
|
+
{
|
116
|
+
"type": "string"
|
117
|
+
}
|
118
|
+
]
|
119
|
+
},
|
120
|
+
"args": {
|
121
|
+
"type": "array",
|
122
|
+
"minItems": 1,
|
123
|
+
"items": [
|
124
|
+
{
|
125
|
+
"type": "string"
|
126
|
+
}
|
127
|
+
]
|
128
|
+
},
|
129
|
+
"roles_path": {
|
130
|
+
"type": "array",
|
131
|
+
"minItems": 1,
|
132
|
+
"items": [
|
133
|
+
{
|
134
|
+
"type": "string"
|
135
|
+
}
|
136
|
+
]
|
137
|
+
},
|
138
|
+
"data_bags_path": {
|
139
|
+
"type": "array",
|
140
|
+
"minItems": 1,
|
141
|
+
"items": [
|
142
|
+
{
|
143
|
+
"type": "string"
|
144
|
+
}
|
145
|
+
]
|
146
|
+
},
|
147
|
+
"environments_path": {
|
148
|
+
"type": "array",
|
149
|
+
"minItems": 1,
|
150
|
+
"items": [
|
151
|
+
{
|
152
|
+
"type": "string"
|
153
|
+
}
|
154
|
+
]
|
155
|
+
},
|
156
|
+
"run_list": {
|
157
|
+
"type": "array",
|
158
|
+
"minItems": 1,
|
159
|
+
"items": [
|
160
|
+
{
|
161
|
+
"type": "string"
|
162
|
+
}
|
163
|
+
]
|
164
|
+
},
|
165
|
+
"roles": {
|
166
|
+
"type": "array",
|
167
|
+
"minItems": 1,
|
168
|
+
"items": [
|
169
|
+
{
|
170
|
+
"type": "string"
|
171
|
+
}
|
172
|
+
]
|
173
|
+
}
|
174
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/zergrush_vagrant/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "zergrush_vagrant"
|
6
|
+
s.version = ZergrushVagrant::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["MTN Satellite Communications"]
|
9
|
+
s.email = ["Marat.Garafutdinov@mtnsat.com"]
|
10
|
+
s.homepage = "https://github.com/MTNSatelliteComm/zerg"
|
11
|
+
s.license = "MIT"
|
12
|
+
s.summary = "Vagrant driver for zergrush"
|
13
|
+
s.description = "Vagrant driver for zergrush"
|
14
|
+
|
15
|
+
s.required_rubygems_version = ">= 2.0.0"
|
16
|
+
s.rubyforge_project = "zergrush_vagrant"
|
17
|
+
|
18
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
19
|
+
s.add_development_dependency "rake"
|
20
|
+
s.add_development_dependency "zergrush"
|
21
|
+
|
22
|
+
s.add_dependency "vagrant-omnibus"
|
23
|
+
s.add_dependency "vagrant-aws"
|
24
|
+
s.add_dependency "vagrant-libvirt"
|
25
|
+
|
26
|
+
s.files = `git ls-files`.split("\n")
|
27
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
28
|
+
s.require_path = 'lib'
|
29
|
+
|
30
|
+
# metadata that marks this as a zergrush plugin
|
31
|
+
s.metadata = { "zergrushplugin" => "driver" }
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zergrush_vagrant
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MTN Satellite Communications
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: zergrush
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vagrant-omnibus
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vagrant-aws
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vagrant-libvirt
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Vagrant driver for zergrush
|
98
|
+
email:
|
99
|
+
- Marat.Garafutdinov@mtnsat.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- COPYING
|
106
|
+
- LICENSE
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- lib/zergrush_vagrant/erbalize.rb
|
110
|
+
- lib/zergrush_vagrant/init.rb
|
111
|
+
- lib/zergrush_vagrant/renderer.rb
|
112
|
+
- lib/zergrush_vagrant/version.rb
|
113
|
+
- resources/bridging.template
|
114
|
+
- resources/defaults.yaml
|
115
|
+
- resources/hostonly.template
|
116
|
+
- resources/machine.template
|
117
|
+
- resources/main.template
|
118
|
+
- resources/provider.template
|
119
|
+
- resources/tasks_schema.template
|
120
|
+
- zergrush_vagrant.gemspec
|
121
|
+
homepage: https://github.com/MTNSatelliteComm/zerg
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata:
|
125
|
+
zergrushplugin: driver
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 2.0.0
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project: zergrush_vagrant
|
142
|
+
rubygems_version: 2.2.2
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Vagrant driver for zergrush
|
146
|
+
test_files: []
|