lib/chef/knife/cook.rb in knife-solo-0.0.3 vs lib/chef/knife/cook.rb in knife-solo-0.0.4
- old
+ new
@@ -25,10 +25,12 @@
rsync_kitchen
add_patches
+ check_chef_version
+
logging_arg = "-l debug" if config[:verbosity] > 0
stream_command <<-BASH
sudo chef-solo -c #{chef_path}/solo.rb \
-j #{chef_path}/#{node_config} \
#{logging_arg}
@@ -62,19 +64,26 @@
def patch_path
Array(Chef::Config.cookbook_path).first + "/chef_solo_patches/libraries"
end
- # TODO (mat): Let rsync write to /var/chef-solo with sudo somehow
def rsync_kitchen
system %Q{rsync -rlP --rsh="ssh #{ssh_args}" --delete --exclude '.*' ./ :#{chef_path}}
end
def add_patches
run_command "mkdir -p #{patch_path}"
Dir[Pathname.new(__FILE__).dirname.join("patches", "*.rb")].each do |patch|
system %Q{rsync -rlP --rsh="ssh #{ssh_args}" #{patch} :#{patch_path}}
end
+ end
+
+ def check_chef_version
+ constraint = "~>0.10.4"
+ result = run_command <<-BASH
+ ruby -rubygems -e "gem 'chef', '#{constraint}'"
+ BASH
+ raise "The chef gem on #{host} is out of date. Please run `#{$0} prepare #{ssh_args}` to upgrade Chef to #{constraint}." unless result.success?
end
end
end
end