lib/capistrano-chef-solo.rb in yyuu-capistrano-chef-solo-0.0.6 vs lib/capistrano-chef-solo.rb in yyuu-capistrano-chef-solo-0.0.7
- old
+ new
@@ -19,18 +19,28 @@
_cset(:chef_solo_path) { File.join(chef_solo_home, 'chef') }
_cset(:chef_solo_path_children, %w(bundle cache config cookbooks))
desc("Run chef-solo.")
task(:default) {
- # login as chef user if specified
- set(:user, fetch(:chef_solo_user, user))
- set(:ssh_options, fetch(:chef_solo_ssh_options, ssh_options))
+ # preserve original :user and :ssh_options
+ set(:chef_solo_original_user, user)
+ set(:chef_solo_original_ssh_options, ssh_options)
- transaction {
- bootstrap
- update
- }
+ begin
+ # login as chef user if specified
+ set(:user, fetch(:chef_solo_user, user))
+ set(:ssh_options, fetch(:chef_solo_ssh_options, ssh_options))
+
+ transaction {
+ bootstrap
+ update
+ }
+ ensure
+ # restore original :user and :ssh_options
+ set(:user, chef_solo_original_user)
+ set(:ssh_options, chef_solo_original_ssh_options)
+ end
}
task(:bootstrap) {
install_ruby
install_chef
@@ -99,19 +109,18 @@
_cset(:chef_solo_cookbooks_exclude, %w(.hg .git .svn))
# special variable to set multiple cookbooks repositories.
# by default, it will build from :chef_solo_cookbooks_* variables.
_cset(:chef_solo_cookbooks) {
- repository = fetch(:chef_solo_cookbooks_repository, fetch(:chef_solo_cookbook_repository, nil))
+ repository = fetch(:chef_solo_cookbooks_repository, nil)
+ repository = fetch(:chef_solo_cookbook_repository, nil) unless repository # for backward compatibility
name = File.basename(repository, File.extname(repository))
- {
- name => {
- :repository => repository,
- :revision => fetch(:chef_solo_cookbooks_revision, fetch(:chef_solo_cookbook_revision, nil)),
- :cookbooks => fetch(:chef_solo_cookbooks_subdir, fetch(:chef_solo_cookbook_subdir, nil)),
- :cookbooks_exclude => chef_solo_cookbooks_exclude,
- }
- }
+ options = { :repository => repository, :cookbooks_exclude => chef_solo_cookbooks_exclude }
+ options[:revision] = fetch(:chef_solo_cookbooks_revision, nil)
+ options[:revision] = fetch(:chef_solo_cookbook_revision, nil) unless options[:revision] # for backward compatibility
+ options[:cookbooks] = fetch(:chef_solo_cookbooks_subdir, nil)
+ options[:cookbooks] = fetch(:chef_solo_cookbook_subdir, nil) unless options[:cookbooks] # for backward compatibility
+ { name => options }
}
_cset(:chef_solo_repository_cache) { File.expand_path('./tmp/cookbooks-cache') }
def bundle_cookbooks(filename, destination)
dirs = [ File.dirname(filename), destination ].uniq