Sha256: fd55b65b7b0897f6d67496399be1247a4a1b8b632e2d9e44c5dd3ecb6756db74

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

require 'puppetdb'

class PuppetGhostbuster
  class PuppetDB
    def self.client
      @@client ||= ::PuppetDB::Client.new({
        :server => "#{ENV['PUPPETDB_URL'] || 'http://puppetdb:8080'}",
        :pem    => {
          'key'     => ENV['PUPPETDB_KEY_FILE'],
          'cert'    => ENV['PUPPETDB_CERT_FILE'],
          'ca_file' => ENV['PUPPETDB_CACERT_FILE'],
        }
      }, 4)
    end

    def client
      self.class.client
    end

    def self.classes
      @@classes ||= client.request('', 'resources[title] { type = "Class" and nodes { deactivated is null } }').data.map { |r| r['title'] }.uniq
    end

    def classes
      self.class.classes
    end

    def self.resources
      @@resources ||= client.request('', 'resources[type] { nodes { deactivated is null } }').data.map { |r| r['type'] }.uniq
    end

    def resources
      self.class.resources
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-ghostbuster-0.9.0 lib/puppet-ghostbuster/puppetdb.rb