forked from jedi4ever/veewee
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
635 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.DS_Store | ||
gems/* | ||
iso/* | ||
tmp/* | ||
definitions/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,94 @@ | ||
base_dir= File.dirname(__FILE__) | ||
box_definition_dir= File.dirname(__FILE__)+"/"+"definitions" | ||
ENV['GEM_PATH']=File.dirname(__FILE__) | ||
ENV['GEM_HOME']=File.dirname(__FILE__) | ||
|
||
desc 'Default: list option' | ||
task :default => [:test] | ||
def check_environment | ||
begin | ||
require 'vagrant' | ||
rescue LoadError | ||
puts "you need to install depedencies: gem instal vagrant" | ||
exit | ||
end | ||
|
||
begin | ||
require 'net/ssh' | ||
require 'virtualbox' | ||
require 'webrick' | ||
rescue LoadError | ||
puts "hmm you had vagrant installed but are missing the net-ssh or virtualbox gem: gem instal virtualbox net-ssh" | ||
exit | ||
end | ||
end | ||
|
||
#See if all gems and so are installed | ||
check_environment | ||
|
||
#Setup some base variables to use | ||
veewee_dir= File.dirname(__FILE__) | ||
definition_dir= File.expand_path(File.join(veewee_dir, "definitions")) | ||
lib_dir= File.expand_path(File.join(veewee_dir, "lib")) | ||
template_dir=File.expand_path(File.join(veewee_dir, "templates")) | ||
vbox_dir=File.expand_path(File.join(veewee_dir, "tmp")) | ||
iso_dir=File.expand_path(File.join(veewee_dir, "iso")) | ||
ENV['VBOX_USER_HOME']=vbox_dir | ||
|
||
#Load Veewee::Session libraries | ||
Dir.glob(File.join(lib_dir, '**','*.rb')).each {|f| | ||
require f } | ||
|
||
#Initialize | ||
Veewee::Session.setenv({:veewee_dir => veewee_dir, :definition_dir => definition_dir, :template_dir => template_dir, :iso_dir => iso_dir}) | ||
|
||
desc 'Default: list templates' | ||
task :default => [:templates] | ||
|
||
desc 'List templates' | ||
task :templates do | ||
Veewee::Session.list_templates | ||
end | ||
|
||
desc 'Define box' | ||
task :define, [:boxname,:template_name] do |t,args| | ||
if args.to_hash.size!=2 | ||
puts "needs two arguments: rake define['boxname','template_name']" | ||
exit | ||
end | ||
Veewee::Session.define(args.boxname,args.template_name) | ||
end | ||
|
||
desc 'Undefine box' | ||
task :undefine, [:boxname] do |t,args| | ||
if args.to_hash.size!=1 | ||
puts "needs one arguments: rake undefine[\"yourname\"]" | ||
exit | ||
end | ||
Veewee::Session.undefine(args.boxname) | ||
end | ||
|
||
desc 'List Definitions' | ||
task :definitions do | ||
Veewee::Session.list_definitions | ||
end | ||
|
||
desc 'Build box' | ||
task :build, [:box] do |t,args| | ||
box=args.box | ||
if File.directory?("#{box_definition_dir}/#{box}") | ||
if run_box.length!=0 | ||
puts "Executing #{run_box}" | ||
require("#{run_box}") | ||
end | ||
end | ||
|
||
end | ||
|
||
desc 'Test box' | ||
task :test, [:box] do |t,args| | ||
system("puppet apply -v --debug --modulepath=#{base_dir}/modules recipe/site.pp") | ||
end | ||
|
||
desc 'List Boxes' | ||
task :list do | ||
|
||
subdirs=Dir.glob("#{box_definition_dir}/*") | ||
subdirs.each do |sub| | ||
if File.directory?("#{sub}") | ||
run_box=Dir.glob("#{sub}/run.rb") | ||
clean_box=Dir.glob("#{sub}/clean.rb") | ||
if run_box.length!=0 | ||
name=sub.sub(/#{box_dir}\//,'') | ||
puts "rake run['#{name}']" | ||
end | ||
if clean_box.length!=0 | ||
name=sub.sub(/#{box_dir}\//,'') | ||
puts "rake clean['#{name}']" | ||
end | ||
end | ||
end | ||
task :build, [:boxname] do |t,args| | ||
if args.to_hash.size!=1 | ||
puts "needs one arguments: rake build['boxname']" | ||
exit | ||
end | ||
Veewee::Session.build(args.boxname) | ||
end | ||
|
||
desc 'List boxes' | ||
task :boxes do | ||
Veewee::Session.list_boxes | ||
end | ||
|
||
desc 'Remove box' | ||
task :remove_box, [:boxname] do |t,args| | ||
Veewee::Session.remove_box(args.boxname) | ||
end | ||
|
||
desc 'Clean all unfinished builds' | ||
task :clean do | ||
Veewee::Session.clean | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.