#Nifty: Quick script to stop on puppet agents
#See https://confluence.zitcom.dk/display/DRIFT/Reset+Puppet+Cert+on+Agent for details.

if [[ "`hostname`" =~ "puppetmaster" ]]; then
  echo "DONT RUN THIS ON PUPPETMASTER!!!"
  exit 1
else
  PUPID=`ps aux |grep pupp |grep agent |awk '{print $2}'`
  if [ "$?" = "0" ]; then
    for pid in $PUPID; do
    kill -9 $pid
  done
  else
    echo "Not running"
  fi
fi
