Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit f022e9ee36e00139231eb9c2186b659aebe36467 1 parent d487e28
@mitchellh mitchellh authored
View
2  CHANGELOG.md
@@ -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
2  lib/vagrant/provisioners/chef.rb
@@ -150,7 +150,7 @@ def add_role(name)
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
36 lib/vagrant/provisioners/chef_solo.rb
@@ -16,10 +16,23 @@ class Config < Chef::Config
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 @@ def expanded_folders(paths, appended_folder=nil)
# 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 @@ def expanded_folders(paths, appended_folder=nil)
# 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
Please sign in to comment.
Something went wrong with that request. Please try again.