class OctofactsUpdater::Service::LocalFile
Public Class Methods
facts(node, config = {})
click to toggle source
Get the facts from a local file, without using PuppetDB
, SSH
, or any of the other automated methods.
node - A String with the FQDN for which to retrieve facts config - A Hash with configuration settings
Returns a Hash with the facts.
# File lib/octofacts_updater/service/local_file.rb, line 17 def self.facts(node, config = {}) unless config["localfile"].is_a?(Hash) raise ArgumentError, "OctofactsUpdater::Service::LocalFile requires localfile section" end config_localfile = config["localfile"].dup path_raw = config_localfile.delete("path") unless path_raw raise ArgumentError, "OctofactsUpdater::Service::LocalFile requires 'path' in the localfile section" end path = path_raw.gsub("%%NODE%%", node) unless File.file?(path) raise Errno::ENOENT, "OctofactsUpdater::Service::LocalFile cannot find a file at #{path.inspect}" end parse_yaml(File.read(path)) end