Class: PEClient::Resource::PuppetDB

Inherits:
BaseWithPort show all
Defined in:
lib/pe_client/resources/puppet_db.rb,
lib/pe_client/resources/puppet_db/admin.v1.rb,
lib/pe_client/resources/puppet_db/query.v4.rb,
lib/pe_client/resources/puppet_db/metadata.v1.rb,
lib/pe_client/resources/puppet_db/query.v4/nodes.rb,
lib/pe_client/resources/puppet_db/admin.v1/archive.rb,
lib/pe_client/resources/puppet_db/query.v4/reports.rb,
lib/pe_client/resources/puppet_db/query.v4/catalogs.rb,
lib/pe_client/resources/puppet_db/query.v4/factsets.rb

Overview

Interact with PuppetDB

Defined Under Namespace

Classes: AdminV1, MetadataV1, QueryV4

Constant Summary collapse

BASE_PATH =

The base path for PuppetDB endpoints.

"/pdb"
PORT =

Default PuppetDB API Port

8081

Instance Method Summary collapse

Methods inherited from BaseWithPort

#initialize

Constructor Details

This class inherits a constructor from PEClient::Resource::BaseWithPort

Instance Method Details

#admin_v1PuppetDB::AdminV1

Returns:



58
59
60
61
# File 'lib/pe_client/resources/puppet_db.rb', line 58

def admin_v1
  require_relative "puppet_db/admin.v1"
  @admin_v1 ||= PuppetDB::AdminV1.new(@client)
end

#metadata_v1PuppetDB::MetadataV1



64
65
66
67
# File 'lib/pe_client/resources/puppet_db.rb', line 64

def 
  require_relative "puppet_db/metadata.v1"
  @metadata_v1 ||= PuppetDB::MetadataV1.new(@client)
end

#query_v4PuppetDB::QueryV4

Returns:



52
53
54
55
# File 'lib/pe_client/resources/puppet_db.rb', line 52

def query_v4
  require_relative "puppet_db/query.v4"
  @query_v4 ||= PuppetDB::QueryV4.new(@client)
end

#state_overview(unresponsive_threshold:) ⇒ Hash

The state-overview endpoint provides a convenient mechanism for getting counts of nodes based on the status of their last report, or alternatively whether the node is unresponsive or has not reported.

Parameters:

  • unresponsive_threshold (Integer)

    The time (in seconds) since the last report after which a node is considered “unresponsive”.

Returns:

  • (Hash)

See Also:



38
39
40
# File 'lib/pe_client/resources/puppet_db.rb', line 38

def state_overview(unresponsive_threshold:)
  @client.get "#{BASE_PATH}/ext/v1/state-overview", params: {unresponsive_threshold:}
end

#statusHash

The status endpoint implements the Puppet Status API for coordinated monitoring of Puppet services.



47
48
49
# File 'lib/pe_client/resources/puppet_db.rb', line 47

def status
  @client.get "/status/v1/services/puppetdb-status"
end