This repository has been archived by the owner on Oct 4, 2021. It is now read-only.
forked from cargomedia/vagrant-boxes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
62 lines (53 loc) · 2.05 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
require 'rake'
require 'rspec/core/rake_task'
require 'vagrant_boxes'
builders = ENV.has_key?('builder') ? [ENV['builder']] : nil
aws_key_id = ENV['aws_key_id']
aws_key_secret = ENV['aws_key_secret']
vagrant_cloud_username = ENV['vagrant_cloud_username']
vagrant_cloud_access_token = ENV['vagrant_cloud_access_token']
s3_bucket = 'vagrant-boxes.cargomedia.ch'
s3_endpoint = 's3-eu-west-1.amazonaws.com'
url_base = 'http://vagrant-boxes.cargomedia.ch/'
aws = VagrantBoxes::Aws.new(aws_key_id, aws_key_secret)
vagrant_cloud = VagrantCloud::Account.new(vagrant_cloud_username, vagrant_cloud_access_token)
environment = VagrantBoxes::Environment.new(File.dirname(__FILE__), aws, vagrant_cloud)
desc 'Build all boxes'
task :build do |t|
environment.find_templates.each do |template|
puts "Building #{template.name}..."
template.build!(builders)
end
end
desc 'Run serverspec tests (virtualbox build only!)'
task :spec do |t|
environment.find_templates.each do |template|
puts "Validating #{template.name}..."
task = RSpec::Core::RakeTask.new(template.name)
box_path = template.output_path('virtualbox')
File.delete('spec/current.box') if File.symlink?('spec/current.box')
File.symlink(box_path, 'spec/current.box')
if File.basename(template.name).match(/plain$/)
task.pattern = FileList.new('spec/filesystem.rb', 'spec/sudo.rb')
else
task.pattern = FileList.new('spec/filesystem.rb', 'spec/sudo.rb', 'spec/git.rb', 'spec/ruby.rb', 'spec/puppet.rb')
end
task.run_task(true)
end
end
desc 'Release boxes to S3 and Vagrant Cloud'
task :release do |t|
environment.find_templates.each do |template|
version = template.next_version
environment.add_rollback(Proc.new { version.delete })
puts "Releasing #{template.name} version #{version}..."
begin
template.upload!(builders, version, s3_bucket, s3_endpoint)
template.release_vagrant_cloud!(builders, version, url_base)
rescue Exception => e
environment.rollback
throw e
end
end
end