Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Last active March 15, 2016 20:32
Show Gist options
  • Save natemccurdy/df8a2ca00f3783e7931e to your computer and use it in GitHub Desktop.
Save natemccurdy/df8a2ca00f3783e7931e to your computer and use it in GitHub Desktop.
Search for list of classes in puppetserver API
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/df8a2ca00f3783e7931e
# This script searches the puppetserver API for all known classes that match ^pe_.*
# Adjust the search pattern to tailor this script to your particular search pattern.
# Set variables for the curl.
CERT="/etc/puppetlabs/puppet/ssl/certs/pe-internal-classifier.pem"
KEY="/etc/puppetlabs/puppet/ssl/private_keys/pe-internal-classifier.pem"
CACERT="/etc/puppetlabs/puppet/ssl/certs/ca.pem"
/opt/puppetlabs/puppet/bin/curl -s -X GET \
--header "Content-Type: application/json" \
--cert "$CERT" \
--key "$KEY" \
--cacert "$CACERT" \
"https://$(hostname -f):8140/puppet/v3/resource_types/^pe_.*?environment=production&kind=class" | python -m json.tool | grep \"name\"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment