9 let endtime="$(now) + 600"
10 while [ "$endtime" -gt "$(now)" ]; do
11 puppet agent --test --detailed-exitcodes
13 if [ 0 = "$agent_exitcode" ] || [ 2 = "$agent_exitcode" ]; then
19 exit ${agent_exitcode:-99}
23 date=`date +'%Y-%m-%d %H:%M:%S'`
29 function run_puppet() {
33 title "Running puppet on $node"
35 if [[ "$DEBUG" != "0" ]]; then
36 ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C bash -c "'$PUPPET_AGENT'" | tee $TMP_FILE
38 ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C bash -c "'$PUPPET_AGENT'" > $TMP_FILE 2>&1
41 ECODE=${PIPESTATUS[0]}
42 RESULT=$(cat $TMP_FILE)
44 if [[ "$ECODE" != "255" && ! ("$RESULT" =~ 'already in progress') && "$ECODE" != "2" && "$ECODE" != "0" ]]; then
45 # Ssh exits 255 if the connection timed out. Just ignore that.
46 # Puppet exits 2 if there are changes. For real!
47 # Puppet prints 'Notice: Run of Puppet configuration client already in progress' if another puppet process
49 echo "ERROR running puppet on $node: exit code $ECODE"
50 if [[ "$DEBUG" == "0" ]]; then
51 title "Command output follows:"
55 if [[ "$ECODE" == "255" ]]; then
56 title "Connection timed out"
59 if [[ "$ECODE" == "2" ]]; then
63 eval "$return_var=$ECODE"
68 title "$1 exited code: $ECODE"