Class: PuppetGhostbuster::PuppetDB
- Inherits:
-
Object
- Object
- PuppetGhostbuster::PuppetDB
- Defined in:
- lib/puppet-ghostbuster/puppetdb.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.classes ⇒ Object
41 42 43 44 45 46 |
# File 'lib/puppet-ghostbuster/puppetdb.rb', line 41 def self.classes @@classes ||= client.request('', 'resources[title] { type = "Class" and nodes { deactivated is null } group by title }').data.map do |r| r['title'] end end |
.client ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppet-ghostbuster/puppetdb.rb', line 15 def self.client @@client ||= begin = { server: ENV['PUPPETDB_URL'] || @@puppetdb, } if ENV['PE_TOKEN'] token_file = File.(ENV['PE_TOKEN']) [:token] = File.exist?(token_file) ? File.read(token_file) : ENV.fetch('PE_TOKEN') [:cacert] = ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert] else [:pem] = { 'key' => ENV['PUPPETDB_KEY_FILE'] || Puppet[:hostprivkey], 'cert' => ENV['PUPPETDB_CERT_FILE'] || Puppet[:hostcert], 'ca_file' => ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert], } end ::PuppetDB::Client.new(, 4) end end |
.resources ⇒ Object
52 53 54 55 56 |
# File 'lib/puppet-ghostbuster/puppetdb.rb', line 52 def self.resources @@resources ||= client.request('', 'resources[type] { nodes { deactivated is null } group by type }').data.map do |r| r['type'] end end |
Instance Method Details
#classes ⇒ Object
48 49 50 |
# File 'lib/puppet-ghostbuster/puppetdb.rb', line 48 def classes self.class.classes end |
#client ⇒ Object
37 38 39 |
# File 'lib/puppet-ghostbuster/puppetdb.rb', line 37 def client self.class.client end |
#resources ⇒ Object
58 59 60 |
# File 'lib/puppet-ghostbuster/puppetdb.rb', line 58 def resources self.class.resources end |