Merge pull request #9670 from briancain/aloyr-puppet_structured_facts_toyaml_on_provisioner
Aloyr puppet structured facts toyaml on provisioner
This commit is contained in:
commit
f636c30aaa
|
@ -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
|
||||
|
@ -37,6 +38,7 @@ module VagrantPlugins
|
|||
@synced_folder_type = UNSET_VALUE
|
||||
@temp_dir = UNSET_VALUE
|
||||
@working_directory = UNSET_VALUE
|
||||
@structured_facts = UNSET_VALUE
|
||||
end
|
||||
|
||||
def nfs=(value)
|
||||
|
|
|
@ -132,6 +132,22 @@ 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/puppetlabs/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.to_yaml)
|
||||
t.close()
|
||||
@machine.communicate.tap do |comm|
|
||||
comm.upload(t.path, File.join(@config.temp_dir, "vagrant_facts.yaml"))
|
||||
comm.sudo("cp #{config.temp_dir}/vagrant_facts.yaml #{@facter_config_path}")
|
||||
end
|
||||
end
|
||||
|
||||
run_puppet_apply
|
||||
end
|
||||
|
||||
|
@ -213,7 +229,8 @@ module VagrantPlugins
|
|||
|
||||
# Build up the custom facts if we have any
|
||||
facter = nil
|
||||
if !config.facter.empty?
|
||||
# Build up the (non-structured) custom facts if we have any
|
||||
if !config.structured_facts && !config.facter.empty?
|
||||
facts = []
|
||||
config.facter.each do |key, value|
|
||||
facts << "FACTER_#{key}='#{value}'"
|
||||
|
|
|
@ -39,6 +39,7 @@ describe VagrantPlugins::Puppet::Provisioner::Puppet do
|
|||
allow(config).to receive(:environment_variables).and_return(nil)
|
||||
allow(config).to receive(:working_directory).and_return(false)
|
||||
allow(config).to receive(:manifest_file).and_return(manifest_file)
|
||||
allow(config).to receive(:structured_facts).and_return(double("structured_facts"))
|
||||
|
||||
allow_message_expectations_on_nil
|
||||
allow(@module_paths).to receive(:map) { module_paths }
|
||||
|
|
Loading…
Reference in New Issue