diff --git a/lib/vagrant/provisioners/puppet.rb b/lib/vagrant/provisioners/puppet.rb index fcec32c6e..0d5266b46 100644 --- a/lib/vagrant/provisioners/puppet.rb +++ b/lib/vagrant/provisioners/puppet.rb @@ -15,7 +15,7 @@ module Vagrant attr_accessor :options def initialize - @manifest_file = nil + @manifest_file = "default.pp" @manifests_path = "manifests" @module_path = nil @pp_path = "/tmp/vagrant-puppet" @@ -24,13 +24,13 @@ module Vagrant # Returns the manifests path expanded relative to the root path of the # environment. - def expanded_manifests_path(env) - Pathname.new(manifests_path).expand_path(env.root_path) + def expanded_manifests_path(root_path) + Pathname.new(manifests_path).expand_path(root_path) end # Returns the module paths as an array of paths expanded relative to the # root path. - def expanded_module_paths(env) + def expanded_module_paths(root_path) return [] if !module_path # Get all the paths and expand them relative to the root path, returning @@ -38,19 +38,25 @@ module Vagrant paths = module_path paths = [paths] if !paths.is_a?(Array) paths.map do |path| - Pathname.new(path).expand_path(env.root_path) + Pathname.new(path).expand_path(root_path) end end def validate(env, errors) # Calculate the manifests and module paths based on env - this_expanded_manifests_path = expanded_manifests_path(env) - this_expanded_module_paths = expanded_module_paths(env) + this_expanded_manifests_path = expanded_manifests_path(env.root_path) + this_expanded_module_paths = expanded_module_paths(env.root_path) # Manifests path/file validation if !this_expanded_manifests_path.directory? errors.add(I18n.t("vagrant.provisioners.puppet.manifests_path_missing", :path => this_expanded_manifests_path)) + else + expanded_manifest_file = this_expanded_manifests_path.join(manifest_file) + if !expanded_manifest_file.file? + errors.add(I18n.t("vagrant.provisioners.puppet.manifest_missing", + :manifest => expanded_manifest_file.to_s)) + end end # Module paths validation @@ -74,13 +80,9 @@ module Vagrant def prepare # Calculate the paths we're going to use based on the environment - @expanded_manifests_path = config.expanded_manifests_path(env[:vm].env) - @expanded_module_paths = config.expanded_module_paths(env[:vm].env) - @manifest_file = config.manifest_file || "#{env[:vm].config.vm.box}.pp" - - if !@expanded_manifests_path.join(@manifest_file).exist? - raise PuppetError, :manifest_missing, :manifest => @manifest_file - end + @expanded_manifests_path = config.expanded_manifests_path(env[:root_path]) + @expanded_module_paths = config.expanded_module_paths(env[:root_path]) + @manifest_file = @expanded_manifests_path.join(config.manifest_file) set_module_paths share_manifests diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 352d45d2a..8768d6b84 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -597,7 +597,10 @@ en: Puppet properly installed. running_puppet: "Running Puppet with %{manifest}..." manifest_missing: |- - The Puppet %{manifest} manifest is missing. You cannot configure this box. + The configured Puppet manifest is missing. Please specify a path to an + existing manifest: + + %{manifest} manifests_path_missing: "The manifests path specified for Puppet does not exist: %{path}" missing_shared_folders: |- Shared folders that Puppet requires are missing on the virtual machine.