Class: OctofactsUpdater::Service::PuppetDB
- Inherits:
-
Object
- Object
- OctofactsUpdater::Service::PuppetDB
- Defined in:
- lib/octofacts_updater/service/puppetdb.rb
Class Method Summary collapse
-
.facts(node, config = {}) ⇒ Object
Get the facts for a specific node.
-
.puppetdb_url(config = {}) ⇒ Object
Get the puppetdb URL from the configuration or environment.
Class Method Details
.facts(node, config = {}) ⇒ Object
Get the facts for a specific node.
node - A String with the FQDN for which to retrieve facts config - An optional Hash with configuration settings
Returns a Hash with the facts (via octocatalog-diff)
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/octofacts_updater/service/puppetdb.rb', line 17 def self.facts(node, config = {}) fact_obj = OctocatalogDiff::Facts.new( node: node.strip, backend: :puppetdb, puppetdb_url: puppetdb_url(config) ) facts = fact_obj.facts(node) return facts unless facts.nil? raise OctocatalogDiff::Errors::FactSourceError, "Fact retrieval failed for #{node}" end |
.puppetdb_url(config = {}) ⇒ Object
Get the puppetdb URL from the configuration or environment.
config - An optional Hash with configuration settings
Returns a String with the PuppetDB URL
33 34 35 36 37 38 39 40 |
# File 'lib/octofacts_updater/service/puppetdb.rb', line 33 def self.puppetdb_url(config = {}) answer = [ config.fetch("puppetdb", {}).fetch("url", nil), ENV["PUPPETDB_URL"] ].compact raise "PuppetDB URL not configured or set in environment" unless answer.any? answer.first end |