+function run_puppet() {
+ node=$1
+ return_var=$2
+
+ TMP_FILE=`mktemp`
+ ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node.$IDENTIFIER -C "/usr/bin/puppet agent -t" | tee $TMP_FILE
+
+ ECODE=$?
+ RESULT=$(cat $TMP_FILE)
+
+ if [[ "$ECODE" != "255" && ! ("$RESULT" =~ 'already in progress') && "$ECODE" != "2" && "$ECODE" != "0" ]]; then
+ # Puppet exists 255 if the connection timed out. Just ignore that, it's possible that this node is
+ # a compute node that was being shut down.
+ # Puppet exits 2 if there are changes. For real!
+ # Puppet prints 'Notice: Run of Puppet configuration client already in progress' if another puppet process
+ # was already running
+ echo "ERROR updating $node.$IDENTIFIER: exit code $ECODE"
+ fi
+ rm -f $TMP_FILE
+ echo
+ eval "$return_var=$ECODE"
+}
+