Last active
April 11, 2018 16:03
-
-
Save natemccurdy/d1abe94f9688de9d7ea38bfd3b2e8d43 to your computer and use it in GitHub Desktop.
Puppet - Node Classifier Backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# GIST_URL: https://gist.github.com/natemccurdy/d1abe94f9688de9d7ea38bfd3b2e8d43 | |
# Dumps the Node Classifier groups to a file. This file can be used to restore classification. | |
# | |
SCRIPTNAME="$(basename "$0")" | |
PATH="/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin:/opt/puppet/bin:$PATH" | |
PE_CERT=$(puppet agent --configprint hostcert) | |
PE_KEY=$(puppet agent --configprint hostprivkey) | |
PE_CA=$(puppet agent --configprint localcacert) | |
NC_CURL_OPT="-s --cacert $PE_CA --cert $PE_CERT --key $PE_KEY" | |
logger "PUPPET_BACKUP: ${SCRIPTNAME} ---> Starting NC Export" | |
curl $NC_CURL_OPT "https://$(hostname -f):4433/classifier-api/v1/groups" > node_classifier_dump.json | |
if [ $? -ne 0 ]; then | |
logger "PUPPET_BACKUP: ${SCRIPTNAME} ---> [FAILURE] Failed to export NC data, error code: $?" | |
else | |
logger "PUPPET_BACKUP: ${SCRIPTNAME} ---> [SUCCESS] Export Completed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment