-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
33 lines (30 loc) · 1004 Bytes
/
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
require 'rake'
require 'json'
require 'rspec/core/rake_task'
properties_file = 'properties.json'
properties = JSON.parse(File.read(properties_file))
properties.keys.each do |key|
desc "Run provision to #{key}"
namespace :itamae do
desc "Run itamae to #{key}"
task key.split('.')[0] do
ENV['TARGET_HOST'] = key
command = "bundle exec itamae ssh"
command << " -h #{key}"
command << " -u #{properties[key]['ssh_user']}"
command << " -i #{properties[key]['private_key']}"
command << " -p #{properties[key]['ssh_port']}"
command << " -j #{properties_file}"
properties[key]['roles'].each {|role| command << " recipes/#{role}/#{role}.rb"}
puts command
system command
end
end
namespace :serverspec do
desc "Run serverspec to #{key}"
RSpec::Core::RakeTask.new(key.split('.')[0].to_sym) do |t|
ENV['TARGET_HOST'] = key
t.pattern = 'spec/{' + properties[key]['roles'].join(',') + '}/*_spec.rb'
end
end
end