我刚从PE 3.3切换到Puppet Enterprise 3.8。 我使用rake api来创建我的组,类和节点。这在PE 3.8中不再有效,并且除了使用仪表板(https://docs.puppetlabs.com/pe/latest/console_classes_groups.html#adding-nodes-to-a-node-group)之外,似乎没有任何记录方式将节点添加到给定组。
有人能指出一些关于如何自动向组添加节点的文档吗?
答案 0 :(得分:4)
您可以使用Node Classifier API添加组,或将节点添加到组中。您需要在master和include the correct certs with the requests上运行这些curl命令。在下面的命令中,将“fqdn”替换为主服务器的完全限定域名。
curl 'https://fqdn:4433/classifier-api/v1/groups' \
-H "Content-Type: application/json" \
--cert /etc/puppetlabs/puppet/ssl/certs/fqdn.pem \
--key /etc/puppetlabs/puppet/ssl/private_keys/fqdn.pem \
--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem
{
"environment_trumps": false,
"parent": "00000000-0000-4000-8000-000000000000",
"name": "foo",
"variables": {},
"id": "085e2797-32f3-4920-9412-8e9decf4ef65",
"environment": "production",
"classes": {}
},
curl -X POST -H 'Content-Type: application/json' \
--cert /etc/puppetlabs/puppet/ssl/certs/fqdn.pem \
--key /etc/puppetlabs/puppet/ssl/private_keys/fqdn.pem \
--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem \
-d '{ "rule": ["or", ["=", "name", "u38a.vm"]] }' \
https://fqdn:4433/classifier-api/v1/groups/085e2797-32f3-4920-9412-8e9decf4ef65
curl -X POST -H 'Content-Type: application/json' \
--cert /etc/puppetlabs/puppet/ssl/certs/fqdn.pem \
--key /etc/puppetlabs/puppet/ssl/private_keys/fqdn.pem \
--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem \
-d '{ "rule": ["or", ["=", "name", "u38a.vm"], ["=", "name", "u38.vm"]] }' \
https://fqdn:4433/classifier-api/v1/groups/085e2797-32f3-4920-9412-8e9decf4ef65
curl -X POST -H 'Content-Type: application/json' \
--cert $(puppet config print hostcert) \
--key $(puppet config print hostprivkey) \
--cacert $(puppet config print localcacert) \
-d '{"nodes": ["foo.tld", "bar.tld", "baz.tld"]}' \
https://$HOSTNAME:4433/classifier-api/v1/groups/<group id>/pin
更新2016-04-12
从Puppet Enterprise 2016.1.1开始,您可以使用new pin/unpin endpoints of the classifier API更轻松地执行此操作:
curl -X POST -H 'Content-Type: application/json' \
--cert $(puppet config print hostcert) \
--key $(puppet config print hostprivkey) \
--cacert $(puppet config print localcacert) \
-d '{"nodes": ["foo.tld", "bar.tld", "baz.tld"]}' \
https://$HOSTNAME:4433/classifier-api/v1/groups/<group id>/unpin
curl -X POST -H 'Content-Type: application/json' \
--cert $(puppet config print hostcert) \
--key $(puppet config print hostprivkey) \
--cacert $(puppet config print localcacert) \
-d '{"nodes": ["foo.tld", "bar.tld", "baz.tld"]}' \
https://$HOSTNAME:4433/classifier-api/v1/commands/unpin-from-all
使用新的(技术预览)commands/unpin-from-all
端点:
Warning: include(Mage/Webviews/Helper/Data.php): failed to open stream: No such file or directory in /media/ephemeral0/vep_mage-primaries-prod/web/lib/Varien/Autoload.php on line 93
使用所有这些端点,您还可以generate a token提供而不是使用基于证书的身份验证。