diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index 9910c6e05..42815a5f6 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -8,6 +8,7 @@ module VagrantPlugins attr_accessor :binary_path attr_accessor :facter + attr_accessor :structured_facts attr_accessor :hiera_config_path attr_accessor :manifest_file attr_accessor :manifests_path @@ -32,6 +33,7 @@ module VagrantPlugins @module_path = UNSET_VALUE @options = [] @facter = {} + @structured_facts = UNSET_VALUE @synced_folder_type = UNSET_VALUE @temp_dir = UNSET_VALUE @working_directory = UNSET_VALUE @@ -52,6 +54,7 @@ module VagrantPlugins def merge(other) super.tap do |result| result.facter = @facter.merge(other.facter) + result.structured_facts = @facter.merge(other.structured_facts) result.environment_path = @facter.merge(other.environment_path) result.environment = @facter.merge(other.environment) end diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index e7c598140..d6da79100 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -121,6 +121,19 @@ module VagrantPlugins @machine.communicate.upload(local_hiera_path, @hiera_config_path) end + # Build up the structured custom facts if we have any + # With structured facts on, we assume the config.facter is yaml. + if config.structured_facts && !config.facter.empty? + @facter_config_path = "/etc/facter/facts.d/vagrant_facts.yaml" + if windows? + @facter_config_path = "/ProgramData/PuppetLabs/facter/facts.d/vagrant_facts.yaml" + end + t = Tempfile.new("vagrant_facts.yaml") + t.write(config.facter) + t.close() + @machine.communicate.upload(t.path, @facter_config_path) + end + run_puppet_apply end @@ -200,9 +213,9 @@ module VagrantPlugins options << @manifest_file options = options.join(" ") - # Build up the custom facts if we have any + # Build up the (non-structured) custom facts if we have any facter = "" - if !config.facter.empty? + if !config.structured_facts && !config.facter.empty? facts = [] config.facter.each do |key, value| facts << "FACTER_#{key}='#{value}'"