Merge pull request #8775 from lucky-sideburn/master

Added exception if chef.node_path is defined on Vagrantfile but the directory does not exist locally
This commit is contained in:
Brian Cain 2017-08-01 13:22:23 -07:00 committed by GitHub
commit a2d39742a7
4 changed files with 31 additions and 2 deletions

View File

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

View File

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

View File

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

View File

@ -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 = []