9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/nise-bosh-vagrant/cli.rb', line 9
def self.start
opts = Trollop::options do
version NiseBOSHVagrant::VERSION
banner <<-EOS
Based on nise-bosh from NTT Labs and Vagrant from HashiCorp
Requires Vagrant >= 1.2
Usage:
nise-bosh-vagrant [options] <BOSH Release>
Options:
EOS
opt :manifest, "Path to manifest file", :type => :string
opt :nise, "Path to nise-bosh if you don't wish to pull HEAD of master from GitHub", :type => :string
opt :install, "Run install script after preparing the VM"
opt :start, "Start all jobs after installing them (implies --install)"
opt :memory, "Amount of memory to allocate to the VM in MB", :type => :integer, :default => 512
opt :preinstall, "Preinstall hook script", :type => :string
opt :postinstall, "Postinstall hook script", :type => :string
opt :address, "IP address for the VM", :type => :string
opt :bridge, "Use bridged network interface"
end
Trollop::die :manifest, "must provide a manifest file" if opts[:manifest].nil?
Trollop::die :manifest, "must exist" unless File.exist?(opts[:manifest])
Trollop::die :preinstall, "must exist" unless opts[:preinstall].nil? || File.exist?(opts[:preinstall])
Trollop::die :postinstall, "must exist" unless opts[:postinstall].nil? || File.exist?(opts[:postinstall])
Trollop::die :address, "must exist" if opts[:bridge] && opts[:address].nil?
opts[:release] = ARGV[0]
if opts[:start]
opts[:install] = true
end
if ! opts[:bridge]
opts[:address] ||= "192.168.10.10"
end
runner = NiseBOSHVagrant::Runner.new(opts)
runner.generate_vagrantfile
runner.copy_manifest
runner.copy_hook_scripts
runner.generate_install_script
puts "---> Starting Vagrant VM"
runner.start_vm
puts "---> Preparing Vagrant VM"
runner.prepare_vm
if opts[:install]
if opts[:preinstall]
puts "---> Running preinstall script"
runner.run_preinstall_release
end
puts "---> Installing release"
runner.install_release
if opts[:postinstall]
puts "---> Running postinstall script"
runner.run_postinstall_release
end
end
if opts[:start]
puts "---> Starting release"
runner.start_release
end
end
|