Project

General

Profile

« Previous | Next » 

Revision de8a5be7

Added by Alexis Mousset about 8 years ago

Fixes #7911: Add an output to all Rudder commands

View differences:

share/commands/agent-check
# @man - clean lock file if it is too big
# @man - check and restore init files
# @man - check that promises have been properly copied
# @man +
# @man *Options*:
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-c*: run the agent without color output
. "${BASEDIR}/../lib/common.sh"
QUIET=false
while getopts "qc" opt; do
case $opt in
q)
QUIET=true
c)
clear_colors
;;
esac
done
/opt/rudder/bin/check-rudder-agent
if [ $? -eq 0 ]; then
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent check ran without errors.\n"
else
printf "${RED}error${NORMAL}: Rudder agent check failed.\n" 1>&2
exit 1
fi
share/commands/agent-disable
# @description forbid rudder-agent to be run by cron or service
# @man This is useful when you want to temporarily prevent your Rudder agent
# @man from doing any modification to your system.
# @man +
# @man *Options*:
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-c*: run the agent without color output
. "${BASEDIR}/../lib/common.sh"
QUIET=false
while getopts "qc" opt; do
case $opt in
q)
QUIET=true
;;
c)
clear_colors
;;
esac
done
touch /opt/rudder/etc/disable-agent
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent is now disabled.\n"
share/commands/agent-enable
# @man *Options*:
# @man +
# @man *-s*: start rudder-agent in addition to enabling it
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-c*: run the agent without color output
. "${BASEDIR}/../lib/common.sh"
while getopts "s" opt; do
QUIET=false
while getopts "sqc" opt; do
case $opt in
s)
START=y
;;
q)
QUIET=true
;;
c)
clear_colors
;;
esac
done
......
then
$CMD
else
echo "Don't know how to start rudder agent." 1>&2
printf "${RED}error${NORMAL}: Don't know how to start rudder agent.\n" 1>&2
echo "Agent not started !" 1>&2
fi
else
if [ -n "${CMD}" ]
then
echo "rudder-agent has been enabled but not started, use '$CMD' or wait for next cron run"
echo "Next time, use -s option to automatically start it"
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent has been enabled but not started, use '$CMD' or wait for next cron run.\n"
[ "$QUIET" = false ] && echo "You can use the -s option to automatically start it"
else
echo "rudder-agent has been enabled but not started, wait for next cron run"
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent has been enabled but not started, wait for next cron run.\n"
fi
fi
share/commands/agent-inventory
# @man +
# @man *-m*: run the agent with multiline output
"${BASEDIR}/agent-run" -D force_inventory $@
"${BASEDIR}/agent-run -D force_inventory $@"
share/commands/agent-reinit
# @man +
# @man *WARNING*: This command will permanently delete your node uuid and keys, and no configuration will
# @man be applied before re-accepting and configuring the node on the server.
# @man +
# @man *Options*:
# @man +
# @man *-i*: run the agent in information mode, prints basic information
# @man +
# @man *-v*: run the agent in verbose mode, prints detailed information
# @man +
# @man *-d*: run the agent in debug mode, prints low-level information
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-w*: show full strings, never cut output
# @man +
# @man *-c*: run the agent without color output
# @man +
# @man *-r*: run the agent with raw output
# @man +
# @man *-R*: run the agent in completely unparsed mode, with no return code of 1 in case of error. A little faster.
# @man +
# @man *-m*: run the agent with multiline output
VERBOSE=false
QUIET=false
while getopts "iIvdqc" opt; do
case $opt in
i|I|v|d)
VERBOSE=true
QUIET=false
;;
q)
VERBOSE=false
QUIET=true
;;
c)
clear_colors
;;
esac
done
# - replace ppkeys
[ "$VERBOSE" = true ] && echo "Removing the agent keys..."
rm -f /var/rudder/cfengine-community/ppkeys/localhost*
[ "$VERBOSE" = true ] && echo "Generating a new key pair..."
/var/rudder/cfengine-community/bin/cf-key
# - generate a new uuid
[ "$VERBOSE" = true ] && echo "Generating a new uuid..."
if [ -x /opt/rudder/bin/uuidgen ]
then
/opt/rudder/bin/uuidgen > /opt/rudder/etc/uuid.hive
......
fi
# - remove old inventory
[ "$VERBOSE" = true ] && echo "Removing old inventory..."
rm -rf /opt/rudder/var/fusioninventory/*
# - reset cfengine status
"${BASEDIR}/agent-reset"
[ "$VERBOSE" = true ] && echo "Triggering an inventory..."
# - resend inventory
"${BASEDIR}/agent-inventory"
"${BASEDIR}/agent-inventory $@"
share/commands/agent-reset
# @man This won't affect the desired state of the node, but will only
# @man reset the internal state of the agent. It is useful to test a rule
# @man without caching interference or when you have trouble with the promises updates.
# @man +
# @man *Options*:
# @man +
# @man *-i*: run the agent in information mode, prints basic information
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-c*: run the agent without color output
VERBOSE=false
QUIET=false
while getopts "iIvdqc" opt; do
case $opt in
i|I|v|d)
VERBOSE=true
QUIET=false
;;
q)
VERBOSE=false
QUIET=true
;;
c)
clear_colors
;;
esac
done
# Try to remove everything that can block
# - restore initial promises
[ "$VERBOSE" = true ] && echo "Restoring initial promises..."
rm -rf /var/rudder/cfengine-community/inputs/*
cp -r /opt/rudder/share/initial-promises/* /var/rudder/cfengine-community/inputs
# - remove state
[ "$VERBOSE" = true ] && echo "Resetting internal agent state..."
rm -rf /var/rudder/cfengine-community/state/*
rm -f /var/rudder/cfengine-community/*.lmdb
# - remove locks
[ "$VERBOSE" = true ] && echo "Removing all agent locks..."
rm -f /var/rudder/cfengine-community/*lock
# - trigger ncf and tools update on next agent run
[ "$VERBOSE" = true ] && echo "Trigger a policy and tools update..."
rm -f /var/rudder/tools/rudder_tools_updated{,.tmp}
rm -f /var/rudder/ncf/{common,local}/ncf_hash_file
# - remove the disable status
[ "$VERBOSE" = true ] && echo "Enabling the agent if needed..."
rm -f /opt/rudder/etc/disable-agent
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent state has been reset.\n"
share/commands/agent-run
if [ -e /opt/rudder/etc/disable-agent ]; then
printf "${VERSION}\nNode uuid: ${UUID}\n\n"
printf "${RED}error${NORMAL}: The Rudder agent is currently disabled. You can enable it with 'rudder agent enable'.\n"
printf "${RED}error${NORMAL}: The Rudder agent is currently disabled. You can enable it with 'rudder agent enable'.\n" 1>&2
exit 1
fi
/var/rudder/cfengine-community/bin/cf-agent ${VERBOSITY} ${COLOR} -K ${BUNDLE} ${CLASS} | eval ${PRETTY}
"${RUDDER_VAR}/cfengine-community/bin/cf-agent" ${VERBOSITY} ${COLOR} -K ${BUNDLE} ${CLASS} | eval ${PRETTY}
share/commands/agent-update
# @man +
# @man *-d*: run the agent in debug mode, prints low-level information
# @man +
# @man *-q*: run the agent in quiet mode (display only error messages)
# @man +
# @man *-c*: run the agent without color output
. "${BASEDIR}/../lib/common.sh"
VERBOSITY=""
COLOR="-C"
DEBUG_CLASS="-D debug"
while getopts "iIvdic" opt; do
while getopts "iIvdqc" opt; do
case $opt in
i|I)
VERBOSITY="-I -D debug"
VERBOSITY="-I ${DEBUG_CLASS}"
QUIET=false
;;
v)
VERBOSITY="-v"
VERBOSITY="-v ${DEBUG_CLASS}"
QUIET=false
;;
d)
VERBOSITY="-d"
VERBOSITY="-d ${DEBUG_CLASS}"
QUIET=false
;;
q)
VERBOSITY=""
QUIET=true
c)
COLOR=""
;;
esac
done
/var/rudder/cfengine-community/bin/cf-agent ${VERBOSITY} ${COLOR} -K -f failsafe.cf
"${RUDDER_VAR}/cfengine-community/bin/cf-agent" ${VERBOSITY} ${COLOR} -K -f failsafe.cf
if [ $? -eq 0 ]; then
[ "$QUIET" = false ] && printf "${GREEN}ok${NORMAL}: Rudder agent promises were updated.\n"
else
printf "${RED}error${NORMAL}: Rudder agent promises could not be updated.\n" 1>&2
exit 1
fi
share/commands/remote-run
VERBOSITY=""
COLOR="-C"
DEBUG_CLASS="-D debug"
while getopts "iIvdc" opt; do
case $opt in
i|I)
VERBOSITY="-I -D debug"
VERBOSITY="-I ${DEBUG_CLASS}"
;;
v)
VERBOSITY="-v"
VERBOSITY="-v ${DEBUG_CLASS}"
;;
d)
VERBOSITY="-d"
VERBOSITY="-d ${DEBUG_CLASS}"
;;
c)
COLOR=""
share/commands/server-reload-groups
# @man *Options*:
# @man +
# @man *-i*: run the agent in information mode, displays all executed commands
# @man +
# @man *-c*: run the agent without color output
. "${BASEDIR}/../lib/api_call.sh"
share/commands/server-reload-techniques
# @man *Options*:
# @man +
# @man *-i*: run the agent in information mode, displays all executed commands
# @man +
# @man *-c*: run the agent without color output
. "${BASEDIR}/../lib/api_call.sh"
share/lib/common.sh
else
clear_colors
fi
# Paths
$RUDDER_VAR="/var/rudder"

Also available in: Unified diff