diff --git a/config/default.rb b/config/default.rb index 5aebe5891..40da4f8cc 100644 --- a/config/default.rb +++ b/config/default.rb @@ -12,4 +12,7 @@ Hobo::Config.run do |config| config.vm.base_mac = "0800279C2E41" config.vm.project_directory = "/hobo" config.vm.forward_port("ssh", 22, 2222) + + config.chef.cookbooks_path = "cookbooks" + config.chef.provisioning_path = "/tmp/hobo-chef" end \ No newline at end of file diff --git a/lib/hobo.rb b/lib/hobo.rb index d2bcec9e8..603affa4d 100644 --- a/lib/hobo.rb +++ b/lib/hobo.rb @@ -12,6 +12,7 @@ require 'hobo/busy' require 'hobo/util' require 'hobo/config' require 'hobo/env' +require 'hobo/provisioning' require 'hobo/ssh' require 'hobo/vm' diff --git a/lib/hobo/config.rb b/lib/hobo/config.rb index 35ad9d24c..04e6b73ff 100644 --- a/lib/hobo/config.rb +++ b/lib/hobo/config.rb @@ -61,21 +61,28 @@ module Hobo :protocol => protocol } end - + def hd_location=(val) raise Exception.new "disk_storage must be set to a directory" unless File.directory?(val) @hd_location=val end end + class ChefConfig < Base + attr_accessor :cookbooks_path + attr_accessor :provisioning_path + end + class Top < Base attr_accessor :dotfile_name attr_reader :ssh attr_reader :vm + attr_reader :chef def initialize @ssh = SSHConfig.new @vm = VMConfig.new + @chef = ChefConfig.new end end end diff --git a/lib/hobo/provisioning.rb b/lib/hobo/provisioning.rb new file mode 100644 index 000000000..15a050a10 --- /dev/null +++ b/lib/hobo/provisioning.rb @@ -0,0 +1,14 @@ +module Hobo + class Provisioning + include Hobo::Util + + def initialize(vm) + @vm = vm + @vm.share_folder("hobo-provisioning", File.expand_path(Hobo.config.chef.cookbooks_path, Env.root_path), Hobo.config.chef.provisioning_path) + end + + def run + + end + end +end \ No newline at end of file diff --git a/lib/hobo/vm.rb b/lib/hobo/vm.rb index 2ec9cf952..484012985 100644 --- a/lib/hobo/vm.rb +++ b/lib/hobo/vm.rb @@ -62,6 +62,11 @@ error def create share_folder("hobo-root", Env.root_path, Hobo.config.vm.project_directory) + # Create the provisioning object, prior to doing anything so it can + # set any configuration on the VM object prior to creation + provisioning = Provisioning.new(self) + + # The path of righteousness import move_hd if Hobo.config[:vm][:hd_location] persist @@ -70,6 +75,9 @@ error setup_shared_folders start mount_shared_folders + + # Once we're started, run the provisioning + provisioning.run end def destroy diff --git a/test/hobo/provisioning_test.rb b/test/hobo/provisioning_test.rb new file mode 100644 index 000000000..896355e32 --- /dev/null +++ b/test/hobo/provisioning_test.rb @@ -0,0 +1,12 @@ +require File.join(File.dirname(__FILE__), '..', 'test_helper') + +class ProvisioningTest < Test::Unit::TestCase + context "initializing" do + should "setup shared folder on VM" do + File.expects(:expand_path).with(Hobo.config.chef.cookbooks_path, Hobo::Env.root_path).returns("foo") + vm = mock("vm") + vm.expects(:share_folder).with("hobo-provisioning", "foo", Hobo.config.chef.provisioning_path) + Hobo::Provisioning.new(vm) + end + end +end diff --git a/test/hobo/vm_test.rb b/test/hobo/vm_test.rb index 4be2105a9..4acfb8fe1 100644 --- a/test/hobo/vm_test.rb +++ b/test/hobo/vm_test.rb @@ -73,7 +73,9 @@ class VMTest < Test::Unit::TestCase context "creating" do should "create the VM in the proper order" do + prov = mock("prov") create_seq = sequence("create_seq") + Hobo::Provisioning.expects(:new).with(@vm).in_sequence(create_seq).returns(prov) @vm.expects(:import).in_sequence(create_seq) @vm.expects(:persist).in_sequence(create_seq) @vm.expects(:setup_mac_address).in_sequence(create_seq) @@ -81,6 +83,7 @@ class VMTest < Test::Unit::TestCase @vm.expects(:setup_shared_folders).in_sequence(create_seq) @vm.expects(:start).in_sequence(create_seq) @vm.expects(:mount_shared_folders).in_sequence(create_seq) + prov.expects(:run).in_sequence(create_seq) @vm.create end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 1088b6b71..a2efcd59e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -38,6 +38,9 @@ class Test::Unit::TestCase config.vm.base_mac = "42" config.vm.project_directory = "/hobo" config.vm.forward_port("ssh", 22, 2222) + + config.chef.cookbooks_path = "cookbooks" + config.chef.provisioning_path = "/tmp/hobo-chef" end Hobo::Config.execute!