vagrant-hivemind 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 096d7bc5746b1e78bb9df4205c6b6a8bd23d9859
|
4
|
+
data.tar.gz: 5396a552c7076e97a436df6807632aa3f60e605f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f984063526bde33b71cf8d9f7e14784cd35ebdbd2c2a68ed35f59da838fff9162f327899c4aa73eb21d0111c39758fc681152afa92a850eaae5c7d890de9ab8
|
7
|
+
data.tar.gz: ea4215f9ff49e1497317b27ae4b984c23920bbb12ba1eee489237e6c475c12b1f5dc188f2401fbaa40b71b0a361c1b345fc11beb133203358c66cfae878b91fd
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require "erb"
|
3
|
+
|
4
|
+
require "vagrant/hivemind/constants"
|
5
|
+
require "vagrant/hivemind/util"
|
6
|
+
require "vagrant/hivemind/host"
|
7
|
+
|
8
|
+
module Vagrant
|
9
|
+
module Hivemind
|
10
|
+
module Command
|
11
|
+
class Generate < Vagrant.plugin("2", :command)
|
12
|
+
include Vagrant::Hivemind::Constants
|
13
|
+
include Vagrant::Hivemind::Util
|
14
|
+
|
15
|
+
def self.synopsis
|
16
|
+
"Generates a Vagrantfile of the Hive"
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute
|
20
|
+
options = {}
|
21
|
+
|
22
|
+
opts = OptionParser.new do |o|
|
23
|
+
o.banner = "Usage: vagrant hivemind generate [options]"
|
24
|
+
o.separator ""
|
25
|
+
o.separator "Options:"
|
26
|
+
o.separator ""
|
27
|
+
|
28
|
+
o.on("-f", "--force", "Overwrite an existing '#{VAGRANT_FILE}' with a new one") do |f|
|
29
|
+
options[:force] = f
|
30
|
+
end
|
31
|
+
|
32
|
+
o.on("-d", "--directory DIRECTORY", "Specify the directory where '#{HIVE_FILE}' is located (default: current directory)") do |d|
|
33
|
+
options[:directory] = []
|
34
|
+
options[:directory] << d
|
35
|
+
end
|
36
|
+
end.parse!
|
37
|
+
|
38
|
+
root_path = Path.get_root_path_from_options options
|
39
|
+
|
40
|
+
unless HiveFile.exist? root_path
|
41
|
+
@env.ui.error "There is no Hive file in the working directory."
|
42
|
+
return 1
|
43
|
+
end
|
44
|
+
|
45
|
+
hosts = HiveFile.read_from root_path
|
46
|
+
|
47
|
+
if Vagrant::Hivemind::Util::Vagrantfile.exist? root_path
|
48
|
+
if options[:force]
|
49
|
+
write_new_vagrant_file hosts, root_path
|
50
|
+
@env.ui.info "The Vagrantfile has been overwritten."
|
51
|
+
return 0
|
52
|
+
else
|
53
|
+
@env.ui.error "The Vagrantfile already exists!"
|
54
|
+
return 1
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
write_new_vagrant_file hosts, root_path
|
59
|
+
|
60
|
+
0
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
def write_new_vagrant_file(hosts, path)
|
65
|
+
Vagrant::Hivemind::Util::Vagrantfile.generate_hivemind_vagrantfile @env, hosts, path, true
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -141,7 +141,7 @@ module Vagrant
|
|
141
141
|
end
|
142
142
|
|
143
143
|
class Vagrantfile
|
144
|
-
def self.generate_hivemind_vagrantfile(env, hosts, path = Pathname.new(Dir.pwd))
|
144
|
+
def self.generate_hivemind_vagrantfile(env, hosts, path = Pathname.new(Dir.pwd), generate = false)
|
145
145
|
box_types = Vagrant::Hivemind::Constants::BOX_TYPES
|
146
146
|
box_sizes = Vagrant::Hivemind::Constants::BOX_SIZES
|
147
147
|
cache_path = Path.cache_path
|
@@ -157,19 +157,36 @@ module Vagrant
|
|
157
157
|
template = ERB.new template_string
|
158
158
|
template_result = template.result(b)
|
159
159
|
|
160
|
-
|
161
|
-
|
162
|
-
|
160
|
+
if generate
|
161
|
+
vagrant_file = File.new(Vagrant::Hivemind::Constants::VAGRANT_FILE, "w+")
|
162
|
+
else
|
163
|
+
vagrant_file = Tempfile.new("Hivemind_Vagrantfile", path)
|
164
|
+
end
|
165
|
+
vagrant_file.write template_result
|
166
|
+
vagrant_file.close
|
163
167
|
|
164
168
|
env.define_singleton_method :vagrantfile_name= do |vfn| @vagrantfile_name = vfn end
|
165
169
|
env.define_singleton_method :root_path= do |root_path| @root_path = root_path end
|
166
170
|
env.define_singleton_method :local_data_path= do |local_data_path| @local_data_path = local_data_path end
|
167
|
-
env.vagrantfile_name = [File.basename(
|
171
|
+
env.vagrantfile_name = [File.basename(vagrant_file)]
|
168
172
|
env.root_path = path
|
169
173
|
env.local_data_path = local_data_path
|
170
174
|
|
171
175
|
nil
|
172
176
|
end
|
177
|
+
|
178
|
+
def self.exist?(path = Pathname.new(Dir.pwd))
|
179
|
+
File.exist? get_vagrant_file_from_path path
|
180
|
+
end
|
181
|
+
|
182
|
+
private
|
183
|
+
def self.get_vagrant_file_from_path(path)
|
184
|
+
if File.directory? path
|
185
|
+
File.join(path, Vagrant::Hivemind::Constants::VAGRANT_FILE)
|
186
|
+
else
|
187
|
+
path
|
188
|
+
end
|
189
|
+
end
|
173
190
|
end
|
174
191
|
|
175
192
|
class Ansible
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-hivemind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nap Ramirez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- keys/id_rsa.pub
|
75
75
|
- lib/vagrant/hivemind.rb
|
76
76
|
- lib/vagrant/hivemind/commands/desc.rb
|
77
|
+
- lib/vagrant/hivemind/commands/generate.rb
|
77
78
|
- lib/vagrant/hivemind/commands/halt.rb
|
78
79
|
- lib/vagrant/hivemind/commands/init.rb
|
79
80
|
- lib/vagrant/hivemind/commands/kill.rb
|