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.
This commit is contained in:
Ryan Schlesinger 2011-04-12 16:40:52 -07:00 committed by Mitchell Hashimoto
parent d7fe7f36fb
commit ab2fff4b5b
3 changed files with 24 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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.