From ab2fff4b5b29e26399a74ede9e08ce5d4fc9bc49 Mon Sep 17 00:00:00 2001 From: Ryan Schlesinger Date: Tue, 12 Apr 2011 16:40:52 -0700 Subject: [PATCH] Adding extra runtime config options for chef. Adding chef.binary_path and chef.binary_env to the config options for controlling where to find chef-solo/chef-client and how to run them. --- lib/vagrant/provisioners/chef.rb | 4 ++++ lib/vagrant/provisioners/chef_server.rb | 12 ++++++++++-- lib/vagrant/provisioners/chef_solo.rb | 12 ++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/provisioners/chef.rb b/lib/vagrant/provisioners/chef.rb index b4809922c..9c8336cb8 100644 --- a/lib/vagrant/provisioners/chef.rb +++ b/lib/vagrant/provisioners/chef.rb @@ -81,6 +81,8 @@ module Vagrant attr_accessor :https_proxy_user attr_accessor :https_proxy_pass attr_accessor :no_proxy + attr_accessor :binary_path + attr_accessor :binary_env def initialize @provisioning_path = "/tmp/vagrant-chef" @@ -93,6 +95,8 @@ module Vagrant @https_proxy_user = nil @https_proxy_pass = nil @no_proxy = nil + @binary_path = nil + @binary_env = nil end # Returns the run list for the provisioning diff --git a/lib/vagrant/provisioners/chef_server.rb b/lib/vagrant/provisioners/chef_server.rb index a1e456682..c3cf0828e 100644 --- a/lib/vagrant/provisioners/chef_server.rb +++ b/lib/vagrant/provisioners/chef_server.rb @@ -41,7 +41,7 @@ module Vagrant end def provision! - verify_binary("chef-client") + verify_binary(chef_client_binary) chown_provisioning_folder create_client_key_folder upload_validation_key @@ -79,7 +79,7 @@ module Vagrant def run_chef_client commands = ["cd #{config.provisioning_path}", - "chef-client -c client.rb -j dna.json"] + "#{config.binary_env} #{chef_client_binary} -c client.rb -j dna.json"] env.ui.info I18n.t("vagrant.provisioners.chef.running_client") vm.ssh.execute do |ssh| @@ -93,6 +93,14 @@ module Vagrant end end + def chef_client_binary + if config.binary_path.nil? || config.binary_path.empty? + "chef-client" + else + File.join(config.binary_path, "chef-client") + end + end + def validation_key_path File.expand_path(config.validation_key_path, env.root_path) end diff --git a/lib/vagrant/provisioners/chef_solo.rb b/lib/vagrant/provisioners/chef_solo.rb index 6606593bc..6afdc831b 100644 --- a/lib/vagrant/provisioners/chef_solo.rb +++ b/lib/vagrant/provisioners/chef_solo.rb @@ -33,7 +33,7 @@ module Vagrant end def provision! - verify_binary("chef-solo") + verify_binary(chef_solo_binary) chown_provisioning_folder setup_json setup_solo_config @@ -70,7 +70,7 @@ module Vagrant end def run_chef_solo - commands = ["cd #{config.provisioning_path}", "chef-solo -c solo.rb -j dna.json"] + commands = ["cd #{config.provisioning_path}", "#{config.binary_env} #{chef_solo_binary} -c solo.rb -j dna.json"] env.ui.info I18n.t("vagrant.provisioners.chef.running_solo") vm.ssh.execute do |ssh| @@ -84,6 +84,14 @@ module Vagrant end end + def chef_solo_binary + if config.binary_path.nil? || config.binary_path.empty? + "chef-solo" + else + File.join(config.binary_path, "chef-solo") + end + end + def host_folder_paths(paths) # Convert single cookbook paths such as "cookbooks" or [:vm, "cookbooks"] # into a proper array representation.