Node
The puppet agent uses the node endpoint to obtain basic information about a node. The node name and environment are returned, as well as any classes set by an External Node Classifier and a hash of parameters that may include the node's facts.
If Puppet is configured with an ENC, the returned node may have a different environment than the one specified in the request.
How to retrieve data for a node?
GET /puppet/v3/node/:certname?environment=:environment&transaction_uuid=:transaction_uuid&configured_environment=:environment
Parameters
The GET should be given one parameter:
- transaction_uuid: a unique identifier for the entire transaction (shows up in the report as well)
An optional parameter can be passed to the GET to notify a node classifier that the client requested a specific environment that may differ from the client's current environment:
- configured_environment: the client's configured environment.
Examples
> GET /puppet/v3/node/mycertname?environment=production&transaction_uuid=aff261a2-1a34-4647-8c20-ff662ec11c4c&configured_environment=production HTTP/1.1
> Accept: application/json, text/pson
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 5830
{
"name":"Intense.corp.puppetlabs.net",
"parameters":{
"architecture":"amd64",
"kernel":"Unix",
"blockdevices":"sda,sr0",
"clientversion":"8.3.1",
"clientnoop":"true",
"environment":"production",
...
},
"environment":"production"
}
Facts
The facts endpoint allows you to set the facts for the node name you specify.
Save
Stores information for a node. The request body should contain facts in JSON format.
PUT /puppet/v3/facts/:nodename?environment=:environment
Parameters
The facts endpoints in puppet have no parameters.
Example
PUT /puppet/v3/facts/elmo.mydomain.com?environment=:environment
Content-Type: application/json
{
"name": "elmo.mydomain.com",
"values": {
"architecture": "amd64",
"kernel": "linux",
"domain": "local",
"macaddress": "91:15:36:8c:33:v9",
"osfamily": "linux",
"operatingsystem": "linux",
"facterversion": "3.8.2",
"fqdn": "plum.mydomain.com",
},
"timestamp": "2022-10-20 15:10:11 -0800",
"expiration": "2022-10-20 15:10:11 -0800"
}
HTTP/1.1 200 OK
Content-Type: application/json
Report
In technical terms, this section describes the Puppet master's report endpoint and the Report Format 6 schema. See also the documentation.
Clients can send reports to the master via http or https using the report endpoint. When a report is received by the master, it is processed by the report processors that have been configured to be triggered when a report is received. One such report processor, for example, handles the storage of reports in PuppetDB.
Save
The http(s) endpoint for reporting to the master is as follows:
PUT /puppet/v3/report/:nodename?environment=:environment
Parameters
The report endpoints in puppet have no parameters.
Content
The Puppet Runtime typically generates report content, which consists of a JSON serialization of Puppet::Transaction::Report object contains a structure of objects with the following runtime types:
Puppet::Util::Log
Puppet::Util::Metric
Puppet::Resource::Status
Puppet::Transaction::Event
This JSON serialization adheres to the report JSON schema of the endpoint.
File Content
The endpoint file_content returns the contents of the specified file.
Find
Getting a file
GET /puppet/v3/file_content/:mount_point/:name
The path to the endpoint includes a:mount point, which can be of the following types:
Custom file serving mounts specified in fileserver.conf.
modules/<MODULE> —- a semi-magical mount point that allows access to the files subdirectory of <MODULE>.
plugins —- a highly magical mount point that combines the lib directories of all modules. Used to sync plugins; not intended for general use. Sub-paths can't be specified per module.
pluginfacts —- a highly magical mount point that combines the facts.d directories of all modules. Used for synchronizing external facts; not for general consumption. Sub-paths can't be specified per module.
tasks/MODULE> —- a semi-magical mount point that allows access to files in the <MODULE> tasks subdirectory.
Parameters
The file_content endpoints in puppet have no parameters.
Notes > Responses
File found
GET /puppet/v3/file_content/modules/example/my_file?environment=env
Accept: application/octet-stream
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 30
this is my file
File not found
GET /puppet/v3/file_content/modules/example/not_found?environment=env
Accept: application/octet-stream
HTTP/1.1 404 Not Found
Content-Type: text/plain
Not Found: Could not find file_content modules/example/not_found
File Bucket File
The file_bucket_file endpoint manages the file bucket's contents. All file access is controlled by the md5 checksum of the file contents, which is represented as :md5. When :filename is used, it refers to the full absolute path of the file on the client system.
This is typically used as an error check to ensure that the correct file is retrieved. Because the file bucket does not distinguish between environments, the environment is required in all requests but ignored.
Find
How to retrieve the contents of a file?
GET /puppet/v3/file_bucket_file/:md5?environment=:environment
GET /puppet/v3/file_bucket_file/:md5/:original_path?environment=:environment
If the file is present, this will return its contents. If :original_path is specified, the contents will be sent only if the file was previously uploaded with the same path.
Head
Check to see if a file exists in the filebucket.
HEAD /puppet/v3/file_bucket_file/:md5?environment=:environment
HEAD /puppet/v3/file_bucket_file/:md5/:original_path?environment=:environment
Save
Saving a file to the filebucket.
PUT /puppet/v3/file_bucket_file/:md5?environment=:environment
PUT /puppet/v3/file_bucket_file/:md5/:original_path?environment=:environment
The file's contents should be included in the body. The file is saved using the md5 sum of its contents. If :original_path is specified, the path is added to a list for the given file. If the md5 sum in the request is incorrect, the file will be saved with the correct checksum instead.
Parameters
The file_bucket_file endpoints in puppet have no parameters.
Examples
Retrieving a file
> GET /puppet/v3/file_bucket_file/md5/4949e56d376cc80ce5387e8e89a75396//home/user/myfile.txt?environment=production HTTP/1.1
> Accept: application/octet-stream
< HTTP/1.1 200 OK
< Content-Length: 32
< This is the file content
Saving a file
> PUT /puppet/v3/file_bucket_file/md5/eb61eead90e3b899c6bcbe27ac581660//home/user/myfile.txt?environment=production HTTP/1.1
> Content-Type: application/octet-stream
> Content-Length: 32
> This is the file content
< HTTP/1.1 200 OK
Frequently Asked Questions
What is Puppet?
Puppet allows you to specify which software and configuration a system requires and then maintain that state after initial setup.
What are the advantages of using Puppet Forge?
You can use Puppet to access the Puppet Forge library of over 6,000 modules. Unlike Ansible, Puppet Forge employs a system that makes it easy to see which modules have been proven to work and which have not.
How does Puppet enlist its features?
Puppet is an open-source system management tool for DevOps. It's used to centralize and automate configuration management.
Is Puppet still used?
Puppet is used to manage data servers at Oracle, Google, and other well-known companies.
Conclusion
In this article, we took an overview of Puppet v3 API and covered different aspects and parameters with detailed examples.
Want To Learn More About brand-new technologies? We Have A Whole Category, visit Coding Ninjas or explore yourself in the following links:
Data Structures and Algorithms, Competitive Programming, Learn Java, Web technologies, Mobile technologies, Interview Questions, Interview Puzzles, Node.Js Web applications, Communications Skills, and Aptitude.