diff --git a/plugins/provisioners/chef/config/chef_zero.rb b/plugins/provisioners/chef/config/chef_zero.rb index 93a036cd7..d02f78f6f 100644 --- a/plugins/provisioners/chef/config/chef_zero.rb +++ b/plugins/provisioners/chef/config/chef_zero.rb @@ -79,6 +79,13 @@ module VagrantPlugins if !present?(Array(nodes_path)) errors << I18n.t("vagrant.config.chef.nodes_path_empty") + else + missing_paths = Array.new + nodes_path.each { |dir| missing_paths << dir[1] if !File.exists? dir[1] } + # If it exists at least one path on disk it's ok for Chef provisioning + if missing_paths.size == nodes_path.size + errors << I18n.t("vagrant.config.chef.nodes_path_missing", path: missing_paths.to_s) + end end if environment && environments_path.empty? diff --git a/plugins/provisioners/chef/provisioner/chef_solo.rb b/plugins/provisioners/chef/provisioner/chef_solo.rb index 64876ffde..cc613af8a 100644 --- a/plugins/provisioners/chef/provisioner/chef_solo.rb +++ b/plugins/provisioners/chef/provisioner/chef_solo.rb @@ -87,7 +87,8 @@ module VagrantPlugins key = Digest::MD5.hexdigest(local_path) remote_path = "#{guest_provisioning_path}/#{key}" else - @machine.ui.warn(I18n.t("vagrant.provisioners.chef.cookbook_folder_not_found_warning", + appended_folder = "cookbooks" if appended_folder.nil? + @machine.ui.warn(I18n.t("vagrant.provisioners.chef.#{appended_folder}_folder_not_found_warning", path: local_path.to_s)) next end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 6513577b7..a3dfae0de 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1584,6 +1584,8 @@ en: Missing required value for `chef.nodes_path'. environment_path_missing: |- Environment path not found: %{path} + nodes_path_missing: |- + Path specified for `nodes_path` does not exist: %{path} environment_path_required: |- When 'environment' is specified, you must provide 'environments_path'. cookbooks_path_missing: |- @@ -2163,8 +2165,16 @@ en: The chef binary (either `chef-solo` or `chef-client`) was not found on the VM and is required for chef provisioning. Please verify that chef is installed and that the binary is available on the PATH. - cookbook_folder_not_found_warning: + cookbooks_folder_not_found_warning: "The cookbook path '%{path}' doesn't exist. Ignoring..." + nodes_folder_not_found_warning: + "The node path '%{path}' doesn't exist. Ignoring..." + data_bags_folder_not_found_warning: + "The databag path '%{path}' doesn't exist. Ignoring..." + roles_folder_not_found_warning: + "The role path '%{path}' doesn't exist. Ignoring..." + environments_folder_not_found_warning: + "The environment path '%{path}' doesn't exist. Ignoring..." json: "Generating chef JSON and uploading..." client_key_folder: "Creating folder to hold client key..." generating_node_name: |- diff --git a/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb b/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb index 1767da562..c674a2767 100644 --- a/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb +++ b/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb @@ -110,6 +110,17 @@ describe VagrantPlugins::Chef::Config::ChefZero do end end + context "when an element of nodes_path does not exist on disk" do + it "returns an error" do + nodes_path = ["/path/to/nodes/that/will/never/exist"] + subject.nodes_path = nodes_path + subject.finalize! + expect(errors).to include(I18n.t("vagrant.config.chef.nodes_path_missing", + path: nodes_path + )) + end + end + context "when the nodes_path is an empty array" do it "returns an error" do subject.nodes_path = []