Class: PEClient::Resource::PuppetV3
- Inherits:
-
BaseWithPort
- Object
- BaseWithPort
- PEClient::Resource::PuppetV3
- Defined in:
- lib/pe_client/resources/puppet.v3.rb,
lib/pe_client/resources/puppet.v3/file_bucket.rb,
lib/pe_client/resources/puppet.v3/file_metadata.rb
Overview
Server-specific Puppet API endpoints.
Defined Under Namespace
Classes: FileBucket, FileMetadata
Constant Summary collapse
- BASE_PATH =
The base path for Puppet API v3 endpoints.
"/puppet/v3"- PORT =
Default Puppet API Port
8140
Instance Method Summary collapse
-
#catalog(node_name:, environment: nil) ⇒ Hash
Returns a catalog for the specified node name given the provided facts.
-
#environment_classes(environment:) ⇒ Hash
The environment classes API serves as a replacement for the Puppet resource type API for classes, which was removed in Puppet.
-
#environment_modules(environment: nil) ⇒ Array<Hash>, Hash
The environment modules API returns information about what modules are installed for the requested environment.
-
#facts(node_name:, values:, timestamp:, expiration:, environment: nil) ⇒ Hash
Allows setting the facts for the specified node name.
- #file_bucket ⇒ PEClient::Resource::PuppetV3::FileBucket
-
#file_content(mount_point:, name:) ⇒ String
Returns the contents of the specified file.
- #file_metadata ⇒ PEClient::Resource::PuppetV3::FileMetadata
-
#node(certname:, environment: nil, transaction_uuid: nil, configured_environment: nil) ⇒ Hash
The returned information includes the node name and environment, and optionally any classes set by an External Node Classifier and a hash of parameters which may include the node’s facts.
-
#report(node_name:, environment:, report:) ⇒ Hash
This endpoint allows clients to send reports to the master.
-
#static_file_content(file_path:) ⇒ String
The static_file_content endpoint returns the standard output of a
code-content-commandscript, which should output the contents of a specific version of a ‘file resource` that has a source attribute with apuppet:///URI value.
Methods inherited from BaseWithPort
Constructor Details
This class inherits a constructor from PEClient::Resource::BaseWithPort
Instance Method Details
#catalog(node_name:, environment: nil) ⇒ Hash
Returns a catalog for the specified node name given the provided facts.
39 40 41 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 39 def catalog(node_name:, environment: nil) @client.get File.join("#{BASE_PATH}/catalog", node_name), params: {environment:}.compact end |
#environment_classes(environment:) ⇒ Hash
The environment classes API serves as a replacement for the Puppet resource type API for classes, which was removed in Puppet.
116 117 118 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 116 def environment_classes(environment:) @client.get "#{BASE_PATH}/environment_classes", params: {environment:} end |
#environment_modules(environment: nil) ⇒ Array<Hash>, Hash
The environment modules API returns information about what modules are installed for the requested environment.
127 128 129 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 127 def environment_modules(environment: nil) @client.get "#{BASE_PATH}/environment_modules", params: {environment:}.compact end |
#facts(node_name:, values:, timestamp:, expiration:, environment: nil) ⇒ Hash
Allows setting the facts for the specified node name.
69 70 71 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 69 def facts(node_name:, values:, timestamp:, expiration:, environment: nil) @client.put File.join("#{BASE_PATH}/facts", node_name), body: {name: node_name, values:, timestamp:, expiration:}, params: {environment:}.compact end |
#file_bucket ⇒ PEClient::Resource::PuppetV3::FileBucket
144 145 146 147 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 144 def file_bucket require_relative "puppet.v3/file_bucket" @file_bucket ||= PuppetV3::FileBucket.new(@client) end |
#file_content(mount_point:, name:) ⇒ String
Returns the contents of the specified file.
90 91 92 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 90 def file_content(mount_point:, name:) @client.get File.join("#{BASE_PATH}/file_content", mount_point, name), headers: {"Content-Type": "application/octet-stream", Accept: "application/octet-stream"} end |
#file_metadata ⇒ PEClient::Resource::PuppetV3::FileMetadata
150 151 152 153 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 150 def require_relative "puppet.v3/file_metadata" @file_metadata ||= PuppetV3::FileMetadata.new(@client) end |
#node(certname:, environment: nil, transaction_uuid: nil, configured_environment: nil) ⇒ Hash
The returned information includes the node name and environment, and optionally any classes set by an External Node Classifier and a hash of parameters which may include the node’s facts. The returned node may have a different environment from the one given in the request if Puppet is configured with an ENC.
54 55 56 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 54 def node(certname:, environment: nil, transaction_uuid: nil, configured_environment: nil) @client.get File.join("#{BASE_PATH}/node", certname), params: {environment:, transaction_uuid:, configured_environment:}.compact end |
#report(node_name:, environment:, report:) ⇒ Hash
This endpoint allows clients to send reports to the master. Once received by the master they are processed by the ‘report processors` configured to be triggered when a report is received. As an example, storing reports in PuppetDB is handled by one such report processor.
105 106 107 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 105 def report(node_name:, environment:, report:) @client.put File.join("#{BASE_PATH}/report", node_name), body: report, params: {environment:} end |
#static_file_content(file_path:) ⇒ String
The static_file_content endpoint returns the standard output of a code-content-command script, which should output the contents of a specific version of a ‘file resource` that has a source attribute with a puppet:/// URI value. That source must be a file from the files or tasks directory of a module in a specific environment.
139 140 141 |
# File 'lib/pe_client/resources/puppet.v3.rb', line 139 def static_file_content(file_path:) @client.get File.join("#{BASE_PATH}/static_file_content", file_path) end |