MT#17213 Force deploy_status 'error' in case of non-success Puppet exit code

NOTE: puppet success exit codes are different for different actions:
 - 'puppet agent -t' exit code is '2' if no errors happen,
 - 'puppet agent --enable' exit code is '0' if no errors happen.

Jenkins should detect puppet error exit codes and fail the test job.

Change-Id: I8df33897bd647e53a4f895c79c82749b97c7313c
changes/85/4185/7
Alexander Lutay 9 years ago
parent 0b32e553cb
commit aa73619039

@ -2165,14 +2165,30 @@ ssl_client_verify_header=SSL_CLIENT_VERIFY
environment=$PUPPET
EOF
check_puppet_rc () {
local _puppet_rc="$1"
local _expected_rc="$2"
if [ "${_puppet_rc}" != "${_expected_rc}" ] ; then
# an exit code of '0' happens for 'puppet agent --enable' only,
# an exit code of '2' means there were changes,
# an exit code of '4' means there were failures during the transaction,
# an exit code of '6' means there were both changes and failures.
set_deploy_status "error"
fi
}
case "$DEBIAN_RELEASE" in
squeeze|wheezy)
chroot $TARGET sed -i 's/START=.*/START=yes/' /etc/default/puppet
grml-chroot $TARGET puppet agent --test --waitforcert 30 2>&1 | tee -a /tmp/puppet.log || true
grml-chroot $TARGET puppet agent --test --waitforcert 30 2>&1 | tee -a /tmp/puppet.log
check_puppet_rc "${PIPESTATUS[0]}" "2"
;;
jessie|stretch)
grml-chroot $TARGET puppet agent --enable 2>&1 | tee -a /tmp/puppet.log || true
grml-chroot $TARGET puppet agent --test --waitforcert 30 2>&1 | tee -a /tmp/puppet.log || true
grml-chroot $TARGET puppet agent --enable 2>&1 | tee -a /tmp/puppet.log
check_puppet_rc "${PIPESTATUS[0]}" "0"
grml-chroot $TARGET puppet agent --test --waitforcert 30 2>&1 | tee -a /tmp/puppet.log
check_puppet_rc "${PIPESTATUS[0]}" "2"
;;
esac
fi

Loading…
Cancel
Save