Skip to content

Instantly share code, notes, and snippets.

@nouse
Forked from natemccurdy/get-environments.sh
Created October 13, 2020 09:13
Show Gist options
  • Save nouse/26338a28fef4ec04bc7449b0d8e93538 to your computer and use it in GitHub Desktop.
Save nouse/26338a28fef4ec04bc7449b0d8e93538 to your computer and use it in GitHub Desktop.
Get the list of environments known to a puppet master
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/65676368168708810c29
# Get the list of classes that the Puppetserver knows about.
# https://docs.puppetlabs.com/puppet/latest/reference/http_api/http_environments.html
CERT="$(puppet agent --configprint hostcert)"
CACERT="$(puppet agent --configprint localcacert)"
PRVKEY="$(puppet agent --configprint hostprivkey)"
OPTIONS="--cert ${CERT} --cacert ${CACERT} --key ${PRVKEY}"
MASTER="$(puppet agent --configprint server)"
/opt/puppetlabs/puppet/bin/curl -s -X GET $OPTIONS "https://${MASTER}:8140/puppet/v3/environments" | python -m json.tool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment