Class: OctofactsUpdater::Service::LocalFile
- Defined in:
- lib/octofacts_updater/service/local_file.rb
Class Method Summary collapse
-
.facts(node, config = {}) ⇒ Object
Get the facts from a local file, without using PuppetDB, SSH, or any of the other automated methods.
Methods inherited from Base
Class Method Details
.facts(node, config = {}) ⇒ Object
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.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/octofacts_updater/service/local_file.rb', line 18 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 |