From 37c98b33bc1250af76057ca4b5e49f8305f6407e Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 10 Nov 2022 17:27:37 +0100 Subject: [PATCH] Adding output of return value of puppet to scripts/exec-puppet-agent --- scripts/exec-puppet-agent | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/exec-puppet-agent b/scripts/exec-puppet-agent index 2a07a86..b310664 100755 --- a/scripts/exec-puppet-agent +++ b/scripts/exec-puppet-agent @@ -13,6 +13,7 @@ CONF_DIR="${BASE_DIR}/etc" PUPPET_BASE="/opt/puppetlabs" PUPPET_BIN="${PUPPET_BASE}/bin/puppet" PUPPET_RUN_LOCK="${PUPPET_BASE}/puppet/cache/state/agent_catalog_run.lock" +RETVAL="0" if [[ -f "${BIN_DIR}/functions.rc" ]] ; then . "${BIN_DIR}/functions.rc" @@ -114,10 +115,20 @@ exec_puppet_agent() { cmd+=" --noop" fi debug "Executing: ${cmd}" + set +e eval ${cmd} + RETVAL="$?" + set -e + + local rv_color="${RED}" + if [[ "${RETVAL}" == 0 ]] ; then + rv_color="${CYAN}" + elif [[ "${RETVAL}" == "1" || "${RETVAL}" == "2" ]] ; then + rv_color="${YELLOW}" + fi empty_line - info "${CYAN}Finished${NORMAL}." + info "${CYAN}Finished${NORMAL} with return value of ${rv_color}${RETVAL}${NORMAL}." } #------------------------------------------------------------------------------ @@ -130,6 +141,6 @@ main() { } main "$@" -exit 0 +exit "${RETVAL}" # vim: et list -- 2.39.5