Fix issue where chef solo always expected "cookbooks" folder [GH-638]

This commit is contained in:
Mitchell Hashimoto 2012-01-19 21:06:09 -08:00
parent d487e286f4
commit f022e9ee36
3 changed files with 34 additions and 6 deletions

View File

@ -1,6 +1,8 @@
## 0.9.2 (unreleased)
- Support shell expansions in shared folder guest paths again. [GH-656]
- Fix issue where Chef solo always expected the host to have a
"cookbooks" folder in their directory. [GH-638]
- Fix `forward_agent` not working when outside of blocks. [GH-651]
- Fix issue causing custom guest implementations to not load properly.
- Filter clear screen character out of output on SSH.

View File

@ -150,7 +150,7 @@ module Vagrant
def validate(env, errors)
super
errors.add(I18n.t("vagrant.config.chef.vagrant_as_json_key")) if @json.has_key?(:vagrant)
errors.add(I18n.t("vagrant.config.chef.vagrant_as_json_key")) if json.has_key?(:vagrant)
end
def instance_variables_hash

View File

@ -16,10 +16,23 @@ module Vagrant
attr_accessor :recipe_url
attr_accessor :nfs
def initialize
super
@__default = ["cookbooks", [:vm, "cookbooks"]]
end
# Provide defaults in such a way that they won't override the instance
# variable. This is so merging continues to work properly.
def cookbooks_path
@cookbooks_path || ["cookbooks", [:vm, "cookbooks"]]
@cookbooks_path || _default_cookbook_path
end
# This stores a reference to the default cookbook path which is used
# later. Do not use this publicly. I apologize for not making it
# "protected" but it has to be called by Vagrant internals later.
def _default_cookbook_path
@__default
end
def nfs
@ -86,16 +99,27 @@ module Vagrant
# path element which contains the folder location (:host or :vm)
paths = [paths] if paths.is_a?(String) || paths.first.is_a?(Symbol)
paths.map do |path|
results = []
paths.each do |path|
path = [:host, path] if !path.is_a?(Array)
type, path = path
# Create the local/remote path based on whether this is a host
# or VM path.
local_path = nil
local_path = File.expand_path(path, env[:root_path]) if type == :host
remote_path = nil
if type == :host
# Get the expanded path that the host path points to
local_path = File.expand_path(path, env[:root_path])
# Super hacky but if we're expanded the default cookbook paths,
# and one of the host paths doesn't exist, then just ignore it,
# because that is fine.
if paths.equal?(config._default_cookbook_path) && !File.directory?(local_path)
@logger.info("'cookbooks' folder doesn't exist on defaults. Ignoring.")
next
end
# Path exists on the host, setup the remote path
remote_path = "#{config.provisioning_path}/chef-solo-#{get_and_update_counter(:cookbooks_path)}"
else
@ -113,9 +137,11 @@ module Vagrant
# If we have specified a folder name to append then append it
remote_path += "/#{appended_folder}" if appended_folder
# Return the result
[type, local_path, remote_path]
# Append the result
results << [type, local_path, remote_path]
end
results
end
# Shares the given folders with the given prefix. The folders should