forked from ansible/ansible-examples
/
Rakefile
33 lines (30 loc) · 1019 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
require 'rake'
require 'rspec/core/rake_task'
require 'yaml'
require 'ansible_spec'
properties = AnsibleSpec.get_properties
namespace :serverspec do
properties.each do |property|
property["hosts"].each do |host|
desc "Run serverspec for #{property["name"]}"
RSpec::Core::RakeTask.new(property["name"].to_sym) do |t|
puts "Run serverspec for #{property["name"]} to #{host}"
if host.instance_of?(Hash)
ENV['TARGET_HOST'] = host["uri"]
ENV['TARGET_PORT'] = host["port"].to_s
ENV['TARGET_PRIVATE_KEY'] = host["private_key"]
unless host["user"].nil?
ENV['TARGET_USER'] = host["user"]
else
ENV['TARGET_USER'] = property["user"]
end
else
ENV['TARGET_HOST'] = host
ENV['TARGET_PRIVATE_KEY'] = '~/.ssh/id_rsa'
ENV['TARGET_USER'] = property["user"]
end
t.pattern = 'roles/{' + property["roles"].join(',') + '}/spec/*_spec.rb'
end
end
end
end