plugins/provisioners/puppet/provisioner/puppet.rb in vagrant-unbundled-1.8.5.2 vs plugins/provisioners/puppet/provisioner/puppet.rb in vagrant-unbundled-1.9.1.1
- old
+ new
@@ -205,11 +205,11 @@
options << @manifest_file
options = options.join(" ")
# Build up the custom facts if we have any
- facter = ""
+ facter = nil
if !config.facter.empty?
facts = []
config.facter.each do |key, value|
facts << "FACTER_#{key}='#{value}'"
end
@@ -217,18 +217,39 @@
# If we're on Windows, we need to use the PowerShell style
if windows?
facts.map! { |v| "$env:#{v};" }
end
- facter = "#{facts.join(" ")} "
+ facter = facts.join(" ")
end
puppet_bin = "puppet"
if @config.binary_path
puppet_bin = File.join(@config.binary_path, puppet_bin)
end
- command = "#{facter} #{puppet_bin} apply #{options}"
+ env_vars = nil
+ if !config.environment_variables.nil? && !config.environment_variables.empty?
+ env_vars = config.environment_variables.map do |env_key, env_value|
+ "#{env_key}=\"#{env_value}\""
+ end
+
+ if windows?
+ env_vars.map! do |env_var_string|
+ "$env:#{env_var_string}"
+ end
+ end
+
+ env_vars = env_vars.join(" ")
+ end
+
+ command = [
+ env_vars,
+ facter,
+ puppet_bin,
+ "apply",
+ options
+ ].compact.map(&:to_s).join(" ")
if config.working_directory
if windows?
command = "cd #{config.working_directory}; if ($?) \{ #{command} \}"
else
command = "cd #{config.working_directory} && #{command}"