From 9ab3a6e1973a9f7fdec55a4bb48c8df6be931362 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 30 Apr 2013 12:41:49 +0900 Subject: [PATCH] Add librarian-chef support --- lib/capistrano-paratrooper-chef.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/capistrano-paratrooper-chef.rb b/lib/capistrano-paratrooper-chef.rb index b45ebe0..5bc4066 100644 --- a/lib/capistrano-paratrooper-chef.rb +++ b/lib/capistrano-paratrooper-chef.rb @@ -187,6 +187,27 @@ def generate_solo_json end namespace :kitchen do + namespace :librarian_chef do + def fetch + require 'librarian/action' + require 'librarian/chef' + + if File.exist? 'Cheffile' + logger.debug("executing librarian-chef") + Librarian::Action::Resolve.new(librarian_env).run + Librarian::Action::Install.new(librarian_env).run + end + rescue LoadError + # pass + end + + def librarian_env + @librarian_env ||= Librarian::Chef::Environment.new + @librarian_env.config_db.local["path"] = cookbooks_paths[0] + @librarian_env + end + end + def ensure_cookbooks abort "No cookbooks found in #{fetch(:cookbooks_directory).inspect}" if kitchen.cookbooks_paths.empty? end @@ -198,6 +219,8 @@ def ensure_working_dir desc "Upload files in kitchen" task :upload, :except => { :no_release => true } do + librarian_chef.fetch + kitchen_paths = [cookbooks_paths, roles_path, databags_path].flatten.compact.select{|d| File.exists?(d)} tarball = Tempfile.new("kitchen.tar") begin