From: Frank Brehm Date: Thu, 10 Nov 2022 16:27:37 +0000 (+0100) Subject: Adding output of return value of puppet to scripts/exec-puppet-agent X-Git-Tag: 0.7.2^2^2~17 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=37c98b33bc1250af76057ca4b5e49f8305f6407e;p=pixelpark%2Fpp-admin-tools.git Adding output of return value of puppet to scripts/exec-puppet-agent --- 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