lib/chef/knife/cook.rb in knife-solo-0.0.10 vs lib/chef/knife/cook.rb in knife-solo-0.0.11
- old
+ new
@@ -11,10 +11,13 @@
class Chef
class Knife
# Approach ported from spatula (https://github.com/trotter/spatula)
# Copyright 2009, Trotter Cashion
class Cook < Knife
+ OMNIBUS_EMBEDDED_PATHS = ["/opt/chef/embedded/bin", "/opt/opscode/embedded/bin"]
+ CHEF_VERSION_CONSTRAINT = ">=0.10.4"
+
include KnifeSolo::SshCommand
include KnifeSolo::KitchenCommand
include KnifeSolo::Tools
banner "knife cook [user@]hostname [json] (options)"
@@ -98,23 +101,14 @@
system! %Q{rsync -rl --rsh="ssh #{ssh_args}" #{patch} :#{adjust_rsync_path(patch_path)}}
end
end
def check_chef_version
- constraint = "~>0.10.4"
result = run_command <<-BASH
- opscode_ruby="/opt/opscode/embedded/bin/ruby"
-
- if command -v $opscode_ruby &>/dev/null
- then
- ruby_bin=$opscode_ruby
- else
- ruby_bin="ruby"
- fi
-
- $ruby_bin -rubygems -e "gem 'chef', '#{constraint}'"
+ export PATH="#{OMNIBUS_EMBEDDED_PATHS.join(":")}:$PATH"
+ ruby -rubygems -e "gem 'chef', '#{CHEF_VERSION_CONSTRAINT}'"
BASH
- raise "Couldn't find Chef #{constraint} on #{host}. Please run `#{$0} prepare #{ssh_args}` to ensure Chef is installed and up to date." unless result.success?
+ raise "Couldn't find Chef #{CHEF_VERSION_CONSTRAINT} on #{host}. Please run `#{$0} prepare #{ssh_args}` to ensure Chef is installed and up to date." unless result.success?
end
def cook
logging_arg = "-l debug" if config[:verbosity] > 0