Created
April 21, 2016 18:54
-
-
Save frozenfoxx/79929a21fcc4824fdb6023513b7c66ac to your computer and use it in GitHub Desktop.
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
# Variables | |
CERTS='' | |
PUPPET=/opt/puppetlabs/bin/puppet | |
CERTFILES=/etc/puppetlabs/puppet/ssl/ca/signed | |
PREFIX=<%= @prefix %> | |
# Logic | |
CERTS=$(${PUPPET} cert list --all | grep -e "^\+\s\"${PREFIX}.*$" | cut -f 2 -d ' ' | sed 's/\"//g') | |
echo "Found $(echo ${CERTS} | wc -w) ephemeral clone certificates." | |
# Loop through the found certificates | |
for cert in ${CERTS}; do | |
LOOKUP=$(nslookup ${cert}) | |
# If it doesn't exist, purge it | |
if [ $? -eq 0 ] ; then | |
echo "${cert} is online." | |
else | |
echo "${cert} offline. Purging..." | |
echo "Removing ${CERTFILES}/${cert}.pem..." | |
rm ${CERTFILES}/${cert}.pem | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment