Clean up the Puppet provisioner a bit
This commit is contained in:
parent
73bff1b457
commit
fc7111734b
|
@ -15,7 +15,7 @@ module Vagrant
|
||||||
attr_accessor :options
|
attr_accessor :options
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@manifest_file = nil
|
@manifest_file = "default.pp"
|
||||||
@manifests_path = "manifests"
|
@manifests_path = "manifests"
|
||||||
@module_path = nil
|
@module_path = nil
|
||||||
@pp_path = "/tmp/vagrant-puppet"
|
@pp_path = "/tmp/vagrant-puppet"
|
||||||
|
@ -24,13 +24,13 @@ module Vagrant
|
||||||
|
|
||||||
# Returns the manifests path expanded relative to the root path of the
|
# Returns the manifests path expanded relative to the root path of the
|
||||||
# environment.
|
# environment.
|
||||||
def expanded_manifests_path(env)
|
def expanded_manifests_path(root_path)
|
||||||
Pathname.new(manifests_path).expand_path(env.root_path)
|
Pathname.new(manifests_path).expand_path(root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the module paths as an array of paths expanded relative to the
|
# Returns the module paths as an array of paths expanded relative to the
|
||||||
# root path.
|
# root path.
|
||||||
def expanded_module_paths(env)
|
def expanded_module_paths(root_path)
|
||||||
return [] if !module_path
|
return [] if !module_path
|
||||||
|
|
||||||
# Get all the paths and expand them relative to the root path, returning
|
# Get all the paths and expand them relative to the root path, returning
|
||||||
|
@ -38,19 +38,25 @@ module Vagrant
|
||||||
paths = module_path
|
paths = module_path
|
||||||
paths = [paths] if !paths.is_a?(Array)
|
paths = [paths] if !paths.is_a?(Array)
|
||||||
paths.map do |path|
|
paths.map do |path|
|
||||||
Pathname.new(path).expand_path(env.root_path)
|
Pathname.new(path).expand_path(root_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate(env, errors)
|
def validate(env, errors)
|
||||||
# Calculate the manifests and module paths based on env
|
# Calculate the manifests and module paths based on env
|
||||||
this_expanded_manifests_path = expanded_manifests_path(env)
|
this_expanded_manifests_path = expanded_manifests_path(env.root_path)
|
||||||
this_expanded_module_paths = expanded_module_paths(env)
|
this_expanded_module_paths = expanded_module_paths(env.root_path)
|
||||||
|
|
||||||
# Manifests path/file validation
|
# Manifests path/file validation
|
||||||
if !this_expanded_manifests_path.directory?
|
if !this_expanded_manifests_path.directory?
|
||||||
errors.add(I18n.t("vagrant.provisioners.puppet.manifests_path_missing",
|
errors.add(I18n.t("vagrant.provisioners.puppet.manifests_path_missing",
|
||||||
:path => this_expanded_manifests_path))
|
: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
|
end
|
||||||
|
|
||||||
# Module paths validation
|
# Module paths validation
|
||||||
|
@ -74,13 +80,9 @@ module Vagrant
|
||||||
|
|
||||||
def prepare
|
def prepare
|
||||||
# Calculate the paths we're going to use based on the environment
|
# Calculate the paths we're going to use based on the environment
|
||||||
@expanded_manifests_path = config.expanded_manifests_path(env[:vm].env)
|
@expanded_manifests_path = config.expanded_manifests_path(env[:root_path])
|
||||||
@expanded_module_paths = config.expanded_module_paths(env[:vm].env)
|
@expanded_module_paths = config.expanded_module_paths(env[:root_path])
|
||||||
@manifest_file = config.manifest_file || "#{env[:vm].config.vm.box}.pp"
|
@manifest_file = @expanded_manifests_path.join(config.manifest_file)
|
||||||
|
|
||||||
if !@expanded_manifests_path.join(@manifest_file).exist?
|
|
||||||
raise PuppetError, :manifest_missing, :manifest => @manifest_file
|
|
||||||
end
|
|
||||||
|
|
||||||
set_module_paths
|
set_module_paths
|
||||||
share_manifests
|
share_manifests
|
||||||
|
|
|
@ -597,7 +597,10 @@ en:
|
||||||
Puppet properly installed.
|
Puppet properly installed.
|
||||||
running_puppet: "Running Puppet with %{manifest}..."
|
running_puppet: "Running Puppet with %{manifest}..."
|
||||||
manifest_missing: |-
|
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}"
|
manifests_path_missing: "The manifests path specified for Puppet does not exist: %{path}"
|
||||||
missing_shared_folders: |-
|
missing_shared_folders: |-
|
||||||
Shared folders that Puppet requires are missing on the virtual machine.
|
Shared folders that Puppet requires are missing on the virtual machine.
|
||||||
|
|
Loading…
Reference in New Issue