Skip to content

Instantly share code, notes, and snippets.

@mjhb
Created August 14, 2015 20:32
Show Gist options
  • Save mjhb/4b5255adcabb03086d62 to your computer and use it in GitHub Desktop.
Save mjhb/4b5255adcabb03086d62 to your computer and use it in GitHub Desktop.
Execute puppet run on a list of remote hosts, when puppet daemon is not available
#!/bin/sh
LOG="puppet.log.`date +%Y-%m-%d.%H-%M-%S`"
OPTS="--server puppet.server.com --onetime --no-daemonize --verbose --detailed-exitcodes --color false"
while read HOST; do
echo "*** Processing $HOST" | tee -a $LOG
ssh -oBatchMode=yes -n $HOST "sudo puppet agent $OPTS 2>&1" 2>&1 | tee -a $LOG
done < hosts.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment