Skip to content

Instantly share code, notes, and snippets.

@asquelt
Last active August 29, 2015 14:24
Show Gist options
  • Save asquelt/7ea58788c518c4e25128 to your computer and use it in GitHub Desktop.
Save asquelt/7ea58788c518c4e25128 to your computer and use it in GitHub Desktop.
# https://docs.puppetlabs.com/pe/latest/nc_classification.html
set -x
facts="{\"fact\":$(puppet facts find $1)}"
#resp=$(curl -X POST -H 'Content-Type: application/json' \
# --data "$facts" \
# --cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem \
# --cert /opt/puppet/share/puppet-dashboard/certs/pe-internal-dashboard.cert.pem \
# --key /opt/puppet/share/puppet-dashboard/certs/pe-internal-dashboard.private_key.pem \
# https://$(hostname -s):4433/classifier-api/v1/classified/nodes/$1)
#resp="$(echo "$resp" | python -m json.tool)"
expl=$(curl -X POST -H 'Content-Type: application/json' \
--data "$facts" \
--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem \
--cert /opt/puppet/share/puppet-dashboard/certs/pe-internal-dashboard.cert.pem \
--key /opt/puppet/share/puppet-dashboard/certs/pe-internal-dashboard.private_key.pem \
https://$(hostname -s):4433/classifier-api/v1/classified/nodes/$1/explanation)
expl="$(echo "$expl" | python -m json.tool)"
facts="$(echo "$facts" | python -m json.tool)"
#echo -en "NODE:$facts\n\nCLASSIFICATION:$resp\n\nEXPLANATION:$expl\n\n" | less -X -E -R
echo "$expl" | less -X -E -R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment