Puppet教程

Puppet RESTful API

Puppet RESTful API

为了提供 Puppet master 和 agent 之间的通信,Puppet 使用了 RESTful API。访问 RESTful API 的 URL 是:
https://brcleprod001:8140/{environment}/{resource}/{key} 
https://brcleprod001:8139/{environment}/{resource}/{key}

安全

Puppet 通常处理安全和 SSL 证书相关的管理任务。尽管如此,在尝试连接到系统时,如果您想在集群外部应用 RESTful API,那么您必须自己处理证书。要为 Puppet 配置安全策略,请使用自动配置文件。

测试 REST API

要测试 RESTful API 连接性,我们可以使用 curl 实用程序.让我们看一个使用 REST API curl 命令检索节点目录的示例:
curl--cert /etc/puppet/ssl/certs/brcleprod001.pem--key 
   /etc/puppet/ssl/private_keys/brcleprod001.pem
在下一系列命令中,我们将设置 SSL 证书。这取决于 SSL 目录的位置和使用的节点名称。例如,考虑以下命令:
curl--insecure-H 'Accept: yaml' 
https://brcleprod002:8140/production/catalog/brcleprod001
以上命令发送用于定义返回格式的标头和用于在生产环境中为 brcleprod001 创建目录并生成给定输出的 RESTful URL:
    ---&id001 !ruby/object:Puppet::Resource::Catalog 
aliases: {} 
applying: false 
classes: [] 
...
让我们考虑另一个示例,从 Puppet 主服务器获取 CA 证书。无需使用其自己签名的 SSL 证书进行身份验证。这在您进行身份验证之前是必需的。
curl--insecure-H 'Accept: s' https://brcleprod001:8140/production/certificate/ca
-----BEGIN CERTIFICATE-----
MIICHTCCAYagAwIBAgIBATANBgkqhkiG9w0BAQUFADAXMRUwEwYDVQQDDAxwdXBw

Puppet Master 和 Agent 共享 API 参考

GET /certificate/{ca, other}  
curl-k-H "Accept: s" https://brcelprod001:8140/production/certificate/ca 
curl-k-H "Accept: s" https://brcleprod002:8139/production/certificate/brcleprod002 

Puppet Master API 参考

经过身份验证的资源(需要有效的签名证书)。
目录
GET /{environment}/catalog/{node certificate name} 
curl-k-H "Accept: pson" https://brcelprod001:8140/production/catalog/myclient
证书吊销清单
GET /certificate_revocation_list/ca 
curl-k-H "Accept: s" https://brcleprod001:8140/production/certificate/ca 
证书申请
GET /{environment}/certificate_requests/{anything} GET 
/{environment}/certificate_request/{node certificate name}  
curl-k-H "Accept: yaml" https://brcelprod001:8140/production/certificate_requests/all 
curl-k-H "Accept: yaml" https://brcleprod001:8140/production/certificate_request/puppetclient 
提交报告
PUT /{environment}/report/{node certificate name}  
curl-k-X PUT-H "Content-Type: text/yaml"-d "{key:value}" https://brcleprod002:8139/production
节点?关于特定节点的事实
GET /{environment}/node/{node certificate name}  
curl-k-H "Accept: yaml" https://brcleprod002:8140/production/node/puppetclient
状态?用于测试
GET /{environment}/status/{anything}  
curl-k-H "Accept: pson" https://brcleprod002:8140/production/certificate_request/puppetclient

Puppet Agent API 参考

当您在机器上添加新代理时,默认情况下,Puppet 代理不侦听 HTTP 请求。我们必须手动启用它。复制 puppet.conf 文件中的以下行:
"listen=true"  
现在,Puppet 代理可以监听 HTTP 请求。
事实
GET /{environment}/facts/{anything}  
curl-k-H "Accept: yaml" https://brcelprod002:8139/production/facts/{anything}
Run-像木偶转或木偶踢一样更新客户端。
curl-k-X PUT-H "Content-Type: text/pson"-d "{}" 
https://brcleprod002:8139/production/run/{anything}
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4