-
Notifications
You must be signed in to change notification settings - Fork 11
/
Rakefile
47 lines (39 loc) · 1.1 KB
/
Rakefile
1
2
3
4
5
6
7
8
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
require 'fileutils'
ALL_MACHINES = 'precise64 centos-6.5'
task :default => [:init, 'vagrant:make']
task :init do
sh 'vagrant', 'plugin', 'install', 'vagrant-omnibus'
end
task :setup do
sh 'bundle', 'install', '--quiet'
rm_rf 'berks-cookbooks'
sh 'bundle', 'exec', 'berks', 'vendor'
end
namespace :vagrant do
task :make, [:machine, :target] => [:up, :provision]
task :remake, [:machine, :target] => [:clean, :up, :provision]
task :up, [:machine] => [:setup] do |t,args|
prepare_args! args
args.machines.each do |machine|
sh 'vagrant', 'up', machine
end
end
task :provision, [:machine] => [:setup] do |t,args|
prepare_args! args
args.machines.each do |machine|
sh 'vagrant', 'provision', machine
end
end
task :clean, [:machine] => [:setup] do |t,args|
prepare_args! args
args.machines.each do |machine|
sh 'vagrant', 'destroy', '-f', machine
end
end
def prepare_args!(args)
args.with_defaults(
:target => ENV['TARGET'],
:machines => ENV.reject { |k,v| v.empty? }.fetch('MACHINE', ALL_MACHINES).split(/[, ]+/)
)
end
end