Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Last active March 18, 2016 23:46
Show Gist options
  • Save natemccurdy/fb01fac7eba615fa8056 to your computer and use it in GitHub Desktop.
Save natemccurdy/fb01fac7eba615fa8056 to your computer and use it in GitHub Desktop.
Update the list of classes in the Puppet NC
#!/bin/bash
# GIST_URL: https://gist.github.com/natemccurdy/fb01fac7eba615fa8056
# Trigger the update-classes endpoint of the Puppet Node Classifier.
# This will update the list of classes available to the NC.
#https://docs.puppetlabs.com/pe/latest/nc_update_classes.html#post-v1update-classes
CONFDIR="$(puppet master --configprint confdir)"
CERT="$(puppet master --confdir "${CONFDIR}" --configprint hostcert)"
CACERT="$(puppet master --confdir "${CONFDIR}" --configprint localcacert)"
PRIVKEY="$(puppet master --confdir "${CONFDIR}" --configprint hostprivkey)"
OPTIONS="--cert ${CERT} --cacert ${CACERT} --key ${PRIVKEY}"
CONSOLE="$(awk '/server: /{print $NF}' "${CONFDIR}/classifier.yaml")"
curl -k -X POST $OPTIONS "https://${CONSOLE}:4433/classifier-api/v1/update-classes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment