Puppet provisioner supports hiera by specifying hiera_config_path
This commit is contained in:
parent
f84b87df2d
commit
6e4a9e15f7
|
@ -2,6 +2,7 @@
|
|||
|
||||
FEATURES:
|
||||
|
||||
- Puppet provisioner now supports Hiera by specifying a `hiera_config_path`.
|
||||
- Added a `working_directory` configuration option to the Puppet apply
|
||||
provisioner so you can specify the working directory when `puppet` is
|
||||
called, making it friendly to Hiera data and such. [GH-1670]
|
||||
|
|
|
@ -3,6 +3,7 @@ module VagrantPlugins
|
|||
module Config
|
||||
class Puppet < Vagrant.plugin("2", :config)
|
||||
attr_accessor :facter
|
||||
attr_accessor :hiera_config_path
|
||||
attr_accessor :manifest_file
|
||||
attr_accessor :manifests_path
|
||||
attr_accessor :module_path
|
||||
|
@ -13,6 +14,7 @@ module VagrantPlugins
|
|||
def initialize
|
||||
super
|
||||
|
||||
@hiera_config_path = UNSET_VALUE
|
||||
@manifest_file = UNSET_VALUE
|
||||
@manifests_path = UNSET_VALUE
|
||||
@module_path = UNSET_VALUE
|
||||
|
@ -25,6 +27,7 @@ module VagrantPlugins
|
|||
def finalize!
|
||||
super
|
||||
|
||||
@hiera_config_path = nil if @hiera_config_path == UNSET_VALUE
|
||||
@manifest_file = "default.pp" if @manifest_file == UNSET_VALUE
|
||||
@manifests_path = "manifests" if @manifests_path == UNSET_VALUE
|
||||
@module_path = nil if @module_path == UNSET_VALUE
|
||||
|
|
|
@ -52,6 +52,21 @@ module VagrantPlugins
|
|||
|
||||
# Verify Puppet is installed and run it
|
||||
verify_binary("puppet")
|
||||
|
||||
# Make sure the temporary directory is properly set up
|
||||
@machine.communicate.tap do |comm|
|
||||
comm.sudo("mkdir -p #{config.temp_dir}")
|
||||
comm.sudo("chmod 0777 #{config.temp_dir}")
|
||||
end
|
||||
|
||||
# Upload Hiera configuration if we have it
|
||||
@hiera_config_path = nil
|
||||
if config.hiera_config_path
|
||||
local_hiera_path = File.expand_path(config.hiera_config_path, @machine.env.root_path)
|
||||
@hiera_config_path = File.join(config.temp_dir, "hiera.yaml")
|
||||
@machine.communicate.upload(local_hiera_path, @hiera_config_path)
|
||||
end
|
||||
|
||||
run_puppet_apply
|
||||
end
|
||||
|
||||
|
@ -78,6 +93,11 @@ module VagrantPlugins
|
|||
options << "--modulepath '#{module_paths.join(':')}'"
|
||||
end
|
||||
|
||||
if @hiera_config_path
|
||||
options << "--hiera_config=#{@hiera_config_path}"
|
||||
end
|
||||
|
||||
options << "--detailed-exitcodes"
|
||||
options << @manifest_file
|
||||
options = options.join(" ")
|
||||
|
||||
|
@ -92,7 +112,7 @@ module VagrantPlugins
|
|||
facter = "#{facts.join(" ")} "
|
||||
end
|
||||
|
||||
command = "#{facter}puppet apply #{options} --detailed-exitcodes || [ $? -eq 2 ]"
|
||||
command = "#{facter}puppet apply #{options} || [ $? -eq 2 ]"
|
||||
if config.working_directory
|
||||
command = "cd #{config.working_directory} && #{command}"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue