Skip to content

Instantly share code, notes, and snippets.

@ripienaar
Created August 6, 2010 11:51
Show Gist options
  • Save ripienaar/511214 to your computer and use it in GitHub Desktop.
Save ripienaar/511214 to your computer and use it in GitHub Desktop.
module MCollective
module Facts
require 'yaml'
# 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.
class Yaml<Base
def get_facts
config = Config.instance
fact_files = config.pluginconf["yaml"].split(":")
facts = {}
fact_files.each do |file|
if File.exist?(file)
facts.merge!(YAML.load_file(file))
else
Log.instance.error("Can't find YAML file to load: #{file}")
end
end
facts
end
end
end
end
# vi:tabstop=4:expandtab:ai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment