Class MCollective::Facts::Yaml_facts
In: plugins/mcollective/facts/yaml_facts.rb
Parent: Base

A factsource that reads a hash of facts from a YAML file

Multiple files can be specified seperated with a : in the config file, they will be merged with later files overriding earlier ones in the list.

Methods

Public Instance methods

[Source]

    # File plugins/mcollective/facts/yaml_facts.rb, line 11
11:             def load_facts_from_source
12:                 config = Config.instance
13:                 logger = Log.instance
14: 
15:                 fact_files = config.pluginconf["yaml"].split(":")
16:                 facts = {}
17: 
18:                 fact_files.each do |file|
19:                     begin
20:                         if File.exist?(file)
21:                             facts.merge!(YAML.load_file(file))
22:                         else
23:                             raise("Can't find YAML file to load: #{file}")
24:                         end
25:                     rescue Exception => e
26:                         logger.error("Failed to load yaml facts from #{file}: #{e.class}: #{e}")
27:                     end
28:                 end
29: 
30:                 facts
31:             end

[Validate]