Support working_directory option for Puppet [GH-1670]
This commit is contained in:
parent
7f32af980e
commit
436a942492
|
@ -1,5 +1,11 @@
|
|||
## 1.2.3 (unreleased)
|
||||
|
||||
FEATURES:
|
||||
|
||||
- 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]
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
- Setting hostnames works properly on SmartOS. [GH-1672]
|
||||
|
|
|
@ -2,18 +2,35 @@ module VagrantPlugins
|
|||
module Puppet
|
||||
module Config
|
||||
class Puppet < Vagrant.plugin("2", :config)
|
||||
attr_accessor :facter
|
||||
attr_accessor :manifest_file
|
||||
attr_accessor :manifests_path
|
||||
attr_accessor :module_path
|
||||
attr_accessor :pp_path
|
||||
attr_accessor :options
|
||||
attr_accessor :facter
|
||||
attr_accessor :temp_dir
|
||||
attr_accessor :working_directory
|
||||
|
||||
def manifest_file; @manifest_file || "default.pp"; end
|
||||
def manifests_path; @manifests_path || "manifests"; end
|
||||
def pp_path; @pp_path || "/tmp/vagrant-puppet"; end
|
||||
def options; @options ||= []; end
|
||||
def facter; @facter ||= {}; end
|
||||
def initialize
|
||||
super
|
||||
|
||||
@manifest_file = UNSET_VALUE
|
||||
@manifests_path = UNSET_VALUE
|
||||
@module_path = UNSET_VALUE
|
||||
@options = []
|
||||
@facter = {}
|
||||
@temp_dir = UNSET_VALUE
|
||||
@working_directory = UNSET_VALUE
|
||||
end
|
||||
|
||||
def finalize!
|
||||
super
|
||||
|
||||
@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
|
||||
@temp_dir = "/tmp/vagrant-puppet" if @temp_dir == UNSET_VALUE
|
||||
@working_directory = nil if @working_directory == UNSET_VALUE
|
||||
end
|
||||
|
||||
# Returns the manifests path expanded relative to the root path of the
|
||||
# environment.
|
||||
|
|
|
@ -19,12 +19,12 @@ module VagrantPlugins
|
|||
root_path = @machine.env.root_path
|
||||
@expanded_manifests_path = @config.expanded_manifests_path(root_path)
|
||||
@expanded_module_paths = @config.expanded_module_paths(root_path)
|
||||
@manifest_file = @config.manifest_file
|
||||
@manifest_file = File.join(@expanded_manifests_path, @config.manifest_file)
|
||||
|
||||
# Setup the module paths
|
||||
@module_paths = []
|
||||
@expanded_module_paths.each_with_index do |path, i|
|
||||
@module_paths << [path, File.join(config.pp_path, "modules-#{i}")]
|
||||
@module_paths << [path, File.join(config.temp_dir, "modules-#{i}")]
|
||||
end
|
||||
|
||||
# Share the manifests directory with the guest
|
||||
|
@ -56,7 +56,7 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def manifests_guest_path
|
||||
File.join(config.pp_path, "manifests")
|
||||
File.join(config.temp_dir, "manifests")
|
||||
end
|
||||
|
||||
def verify_binary(binary)
|
||||
|
@ -92,10 +92,13 @@ module VagrantPlugins
|
|||
facter = "#{facts.join(" ")} "
|
||||
end
|
||||
|
||||
command = "cd #{manifests_guest_path} && #{facter}puppet apply #{options} --detailed-exitcodes || [ $? -eq 2 ]"
|
||||
command = "#{facter}puppet apply #{options} --detailed-exitcodes || [ $? -eq 2 ]"
|
||||
if config.working_directory
|
||||
command = "cd #{config.working_directory} && #{command}"
|
||||
end
|
||||
|
||||
@machine.env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet",
|
||||
:manifest => @manifest_file)
|
||||
:manifest => config.manifest_file)
|
||||
|
||||
@machine.communicate.sudo(command) do |type, data|
|
||||
data.chomp!
|
||||
|
|
Loading…
Reference in New Issue