Skip to content

Commit

Permalink
Fix overzealous errors with chef solo provisioner defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Mar 18, 2013
1 parent 5ad6c2a commit 59282ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,9 @@
## 1.1.2 (unreleased)

BUG FIXES:

- When not specifying a cookbooks_path for chef-solo, an error won't
be shown if "cookbooks" folder is missing.

## 1.1.1 (March 18, 2013)

Expand Down
17 changes: 11 additions & 6 deletions plugins/provisioners/chef/config/chef_solo.rb
Expand Up @@ -22,11 +22,14 @@ def initialize
@encrypted_data_bag_secret = UNSET_VALUE
@encrypted_data_bag_secret_key_path = UNSET_VALUE
@nfs = UNSET_VALUE

@__defaulted_cookbooks_path = false
end

def finalize!
if @cookbooks_path == UNSET_VALUE
@cookbooks_path = [[:host, "cookbooks"], [:vm, "cookbooks"]]
@__defaulted_cookbooks_path = true
end

@data_bags_path = [] if @data_bags_path == UNSET_VALUE
Expand All @@ -52,13 +55,15 @@ def validate(machine)
errors << I18n.t("vagrant.config.chef.run_list_empty") if \
!run_list || run_list.empty?

@cookbooks_path.each do |type, path|
next if type != :host
expanded_path = File.expand_path(path, machine.env.root_path)
if !@__defaulted_cookbooks_path
@cookbooks_path.each do |type, path|
next if type != :host
expanded_path = File.expand_path(path, machine.env.root_path)

if !File.exist?(expanded_path)
errors << I18n.t("vagrant.config.chef.cookbooks_path_missing",
:path => expanded_path)
if !File.exist?(expanded_path)
errors << I18n.t("vagrant.config.chef.cookbooks_path_missing",
:path => expanded_path)
end
end
end

Expand Down

0 comments on commit 59282ba

Please sign in to comment.