From 52c95ce291ef14e8d42958a075ebf9ca7036ebb3 Mon Sep 17 00:00:00 2001 From: Donald Guy Date: Thu, 25 Feb 2016 19:42:58 -0500 Subject: [PATCH] Correctly detect chefdk install --- plugins/provisioners/chef/cap/linux/chef_installed.rb | 4 ++-- plugins/provisioners/chef/cap/omnios/chef_installed.rb | 6 +++--- plugins/provisioners/chef/cap/windows/chef_installed.rb | 2 +- plugins/provisioners/chef/installer.rb | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/provisioners/chef/cap/linux/chef_installed.rb b/plugins/provisioners/chef/cap/linux/chef_installed.rb index aa891c541..c664f90bb 100644 --- a/plugins/provisioners/chef/cap/linux/chef_installed.rb +++ b/plugins/provisioners/chef/cap/linux/chef_installed.rb @@ -5,8 +5,8 @@ module VagrantPlugins module ChefInstalled # Check if Chef is installed at the given version. # @return [true, false] - def self.chef_installed(machine, version) - knife = "/opt/chef/bin/knife" + def self.chef_installed(machine, product, version) + knife = "/opt/#{product}/bin/knife" command = "test -x #{knife}" if version != :latest diff --git a/plugins/provisioners/chef/cap/omnios/chef_installed.rb b/plugins/provisioners/chef/cap/omnios/chef_installed.rb index 2345d3b6a..c1e55ba53 100644 --- a/plugins/provisioners/chef/cap/omnios/chef_installed.rb +++ b/plugins/provisioners/chef/cap/omnios/chef_installed.rb @@ -6,10 +6,10 @@ module VagrantPlugins # TODO: this is the same code as cap/linux/chef_installed, consider merging # Check if Chef is installed at the given version. # @return [true, false] - def self.chef_installed(machine, version) - knife = "/opt/chef/bin/knife" + def self.chef_installed(machine, product, version) + knife = "/opt/#{product}/bin/knife" command = "test -x #{knife}" - + if version != :latest command << "&& #{knife} --version | grep 'Chef: #{version}'" end diff --git a/plugins/provisioners/chef/cap/windows/chef_installed.rb b/plugins/provisioners/chef/cap/windows/chef_installed.rb index b08794833..61335a5cd 100644 --- a/plugins/provisioners/chef/cap/windows/chef_installed.rb +++ b/plugins/provisioners/chef/cap/windows/chef_installed.rb @@ -5,7 +5,7 @@ module VagrantPlugins module ChefInstalled # Check if Chef is installed at the given version. # @return [true, false] - def self.chef_installed(machine, version) + def self.chef_installed(machine, product, version) if version != :latest command = 'if ((&knife --version) -Match "Chef: ' + version.to_s + '"){ exit 0 } else { exit 1 }' else diff --git a/plugins/provisioners/chef/installer.rb b/plugins/provisioners/chef/installer.rb index 3dc5efadc..734136328 100644 --- a/plugins/provisioners/chef/installer.rb +++ b/plugins/provisioners/chef/installer.rb @@ -31,7 +31,7 @@ module VagrantPlugins version: @version.to_s)) @machine.guest.capability(:chef_install, @product, @version, @channel, @options) - if !@machine.guest.capability(:chef_installed, @version) + if !@machine.guest.capability(:chef_installed, @product, @version) raise Provisioner::Base::ChefError, :install_failed end end @@ -40,7 +40,7 @@ module VagrantPlugins # option is given or if the guest does not have Chef installed at the # proper version. def should_install_chef? - @force || !@machine.guest.capability(:chef_installed, @version) + @force || !@machine.guest.capability(:chef_installed, @product, @version) end end end