5 # A factsource that reads a hash of facts from a YAML file
7 # Multiple files can be specified seperated with a : in the
8 # config file, they will be merged with later files overriding
9 # earlier ones in the list.
12 @yaml_file_mtimes = {}
17 def load_facts_from_source
18 config = Config.instance
20 fact_files = config.pluginconf["yaml"].split(File::PATH_SEPARATOR)
23 fact_files.each do |file|
26 facts.merge!(YAML.load_file(file))
28 raise("Can't find YAML file to load: #{file}")
31 Log.error("Failed to load yaml facts from #{file}: #{e.class}: #{e}")
38 # force fact reloads when the mtime on the yaml file change
40 config = Config.instance
42 fact_files = config.pluginconf["yaml"].split(File::PATH_SEPARATOR)
44 fact_files.each do |file|
45 @yaml_file_mtimes[file] ||= File.stat(file).mtime
46 mtime = File.stat(file).mtime
48 if mtime > @yaml_file_mtimes[file]
49 @yaml_file_mtimes[file] = mtime
51 Log.debug("Forcing fact reload due to age of #{file}")