From 337b5fc0f0551aeafa8f2c210f17698ef37791ba Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 9 Feb 2010 19:22:12 -0800 Subject: [PATCH] Chef solo is run now --- lib/hobo/provisioning.rb | 12 ++++++++++++ test/hobo/provisioning_test.rb | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/hobo/provisioning.rb b/lib/hobo/provisioning.rb index 926875e85..9119cecda 100644 --- a/lib/hobo/provisioning.rb +++ b/lib/hobo/provisioning.rb @@ -14,6 +14,7 @@ module Hobo chown_provisioning_folder setup_json setup_solo_config + run_chef_solo end def chown_provisioning_folder @@ -38,6 +39,17 @@ solo SSH.upload!(StringIO.new(solo_file), File.join(Hobo.config.chef.provisioning_path, "solo.rb")) end + def run_chef_solo + logger.info "Running chef recipes..." + SSH.execute do |ssh| + ssh.exec!("cd #{Hobo.config.chef.provisioning_path} && sudo chef-solo -c solo.rb -j dna.json") do |channel, data, stream| + # TODO: Very verbose. It would be easier to save the data and only show it during + # an error, or when verbosity level is set high + logger.info("#{stream}: #{data}") + end + end + end + def cookbooks_path File.join(Hobo.config.chef.provisioning_path, "cookbooks") end diff --git a/test/hobo/provisioning_test.rb b/test/hobo/provisioning_test.rb index 558312957..034dd5926 100644 --- a/test/hobo/provisioning_test.rb +++ b/test/hobo/provisioning_test.rb @@ -68,4 +68,13 @@ config @prov.setup_solo_config end end + + context "running chef solo" do + should "cd into the provisioning directory and run chef solo" do + ssh = mock("ssh") + ssh.expects(:exec!).with("cd #{Hobo.config.chef.provisioning_path} && sudo chef-solo -c solo.rb -j dna.json").once + Hobo::SSH.expects(:execute).yields(ssh) + @prov.run_chef_solo + end + end end