3 # Copyright (C) The Arvados Authors. All rights reserved.
5 # SPDX-License-Identifier: AGPL-3.0
13 let endtime="$(now) + 600"
14 while [ "$endtime" -gt "$(now)" ]; do
15 puppet agent --test --detailed-exitcodes
17 if [ 0 = "$agent_exitcode" ] || [ 2 = "$agent_exitcode" ]; then
23 exit ${agent_exitcode:-99}
27 date=`date +'%Y-%m-%d %H:%M:%S'`
33 function run_puppet() {
37 title "Running puppet on $node"
39 if [[ "$DEBUG" != "0" ]]; then
40 ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C bash -c "'$PUPPET_AGENT'" | tee $TMP_FILE
42 ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C bash -c "'$PUPPET_AGENT'" > $TMP_FILE 2>&1
45 ECODE=${PIPESTATUS[0]}
46 RESULT=$(cat $TMP_FILE)
48 if [[ "$ECODE" != "255" && ! ("$RESULT" =~ 'already in progress') && "$ECODE" != "2" && "$ECODE" != "0" ]]; then
49 # Ssh exits 255 if the connection timed out. Just ignore that.
50 # Puppet exits 2 if there are changes. For real!
51 # Puppet prints 'Notice: Run of Puppet configuration client already in progress' if another puppet process
53 echo "ERROR running puppet on $node: exit code $ECODE"
54 if [[ "$DEBUG" == "0" ]]; then
55 title "Command output follows:"
59 if [[ "$ECODE" == "255" ]]; then
60 title "Connection timed out"
63 if [[ "$ECODE" == "2" ]]; then
67 eval "$return_var=$ECODE"
72 title "$1 exited code: $ECODE"