lib/capistrano-chef-solo.rb in yyuu-capistrano-chef-solo-0.0.7 vs lib/capistrano-chef-solo.rb in yyuu-capistrano-chef-solo-0.0.8
- old
+ new
@@ -13,45 +13,55 @@
configuration.load {
namespace(:"chef-solo") {
_cset(:chef_solo_home) {
capture('echo $HOME').strip
}
- _cset(:chef_solo_version, '10.16.2')
+ _cset(:chef_solo_version, '10.16.4')
_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) {
+ def connect_with_settings()
# preserve original :user and :ssh_options
- set(:chef_solo_original_user, user)
- set(:chef_solo_original_ssh_options, ssh_options)
-
+ set(:_chef_solo_user, user)
+ set(:_chef_solo_ssh_options, ssh_options)
+ set(:_chef_solo_rbenv_ruby_version, rbenv_ruby_version)
begin
# login as chef user if specified
set(:user, fetch(:chef_solo_user, user))
set(:ssh_options, fetch(:chef_solo_ssh_options, ssh_options))
+ set(:rbenv_ruby_version, fetch(:chef_solo_ruby_version, rbenv_ruby_version))
+ yield
+ ensure
+ # restore original :user and :ssh_options
+ set(:user, _chef_solo_user)
+ set(:ssh_options, _chef_solo_ssh_options)
+ set(:rbenv_ruby_version, _chef_solo_rbenv_ruby_version)
+ end
+ end
+ desc("Run chef-solo.")
+ task(:default) {
+ connect_with_settings {
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
+ }
}
+ desc("Show version.")
+ task(:version) {
+ connect_with_settings {
+ run("cd #{chef_solo_path} && #{bundle_cmd} exec chef-solo --version")
+ }
+ }
+
task(:bootstrap) {
install_ruby
install_chef
}
- _cset(:chef_solo_ruby_version) {
- rbenv_ruby_version
- }
task(:install_ruby) {
- set(:rbenv_ruby_version, chef_solo_ruby_version)
set(:rbenv_use_bundler, true)
find_and_execute_task('rbenv:setup')
}
_cset(:chef_solo_gemfile) {