Fix up puppet provisioner a bit
This commit is contained in:
parent
eaf6ce7372
commit
73bff1b457
|
@ -1,3 +1,5 @@
|
||||||
|
require "log4r"
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Provisioners
|
module Provisioners
|
||||||
class PuppetError < Vagrant::Errors::VagrantError
|
class PuppetError < Vagrant::Errors::VagrantError
|
||||||
|
@ -26,12 +28,6 @@ module Vagrant
|
||||||
Pathname.new(manifests_path).expand_path(env.root_path)
|
Pathname.new(manifests_path).expand_path(env.root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the manifest file if set otherwise returns the box name pp file
|
|
||||||
# which may or may not exist.
|
|
||||||
def computed_manifest_file
|
|
||||||
manifest_file || "#{top.vm.box}.pp"
|
|
||||||
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(env)
|
||||||
|
@ -55,11 +51,6 @@ module Vagrant
|
||||||
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
|
|
||||||
if !this_expanded_manifests_path.join(computed_manifest_file).file?
|
|
||||||
errors.add(I18n.t("vagrant.provisioners.puppet.manifest_missing",
|
|
||||||
:manifest => computed_manifest_file))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Module paths validation
|
# Module paths validation
|
||||||
|
@ -75,10 +66,21 @@ module Vagrant
|
||||||
Config
|
Config
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def initialize(env, config)
|
||||||
|
super
|
||||||
|
|
||||||
|
@logger = Log4r::Logger.new("vagrant::provisioners::puppet")
|
||||||
|
end
|
||||||
|
|
||||||
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)
|
@expanded_manifests_path = config.expanded_manifests_path(env[:vm].env)
|
||||||
@expanded_module_paths = config.expanded_module_paths(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
|
||||||
|
|
||||||
set_module_paths
|
set_module_paths
|
||||||
share_manifests
|
share_manifests
|
||||||
|
@ -134,12 +136,13 @@ module Vagrant
|
||||||
def run_puppet_client
|
def run_puppet_client
|
||||||
options = [config.options].flatten
|
options = [config.options].flatten
|
||||||
options << "--modulepath '#{@module_paths.values.join(':')}'" if !@module_paths.empty?
|
options << "--modulepath '#{@module_paths.values.join(':')}'" if !@module_paths.empty?
|
||||||
options << config.computed_manifest_file
|
options << @manifest_file
|
||||||
options = options.join(" ")
|
options = options.join(" ")
|
||||||
|
|
||||||
command = "cd #{manifests_guest_path} && puppet apply #{options}"
|
command = "cd #{manifests_guest_path} && puppet apply #{options}"
|
||||||
|
|
||||||
env[:ui].info I18n.t("vagrant.provisioners.puppet.running_puppet", :manifest => config.computed_manifest_file)
|
env[:ui].info I18n.t("vagrant.provisioners.puppet.running_puppet",
|
||||||
|
:manifest => @manifest_file)
|
||||||
|
|
||||||
env[:vm].channel.sudo(command) do |type, data|
|
env[:vm].channel.sudo(command) do |type, data|
|
||||||
# Output the data with the proper color based on the stream.
|
# Output the data with the proper color based on the stream.
|
||||||
|
|
|
@ -596,7 +596,8 @@ en:
|
||||||
installed on this guest. Puppet provisioning can not continue without
|
installed on this guest. Puppet provisioning can not continue without
|
||||||
Puppet properly installed.
|
Puppet properly installed.
|
||||||
running_puppet: "Running Puppet with %{manifest}..."
|
running_puppet: "Running Puppet with %{manifest}..."
|
||||||
manifest_missing: "The Puppet %{manifest} manifest is missing. You cannot configure this box."
|
manifest_missing: |-
|
||||||
|
The Puppet %{manifest} manifest is missing. You cannot configure this box.
|
||||||
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