We are slowly implementing CF-Engine 3 in our environment. Inevitably, there are occasionally problems on specific systems. Sometimes we need to disable CF-Engine while debugging since the files that are being worked on are maintained by CF-Engine and would be overwritten during the debugging process.
We also put a line in to /etc/cron.d/cfengine to restart it if for some reason it is stopped.
I wrote the attached script which will disable both cf-monitord and cf-execd, and set a flag so that it won’t be started by the cron entry. Actually, the cron entry calls the script to CF-Engine if it is not running.
The only line which might need to be changed is the FLAGDIR, which specifies where to put the flag file.
# usage: # # cfengine.sh [disable | enable | runcheck] # # disable set disable flag, and stop cf-execd and cf-monitord # enable remove disable flag, and start cf-execd and cf-monitord # runcheck check to see that both cf-execd and cf-monitord are running # # anything else, or nothing, just shows the current state
This is the cron entry (put it in /etc/cron.d/cfengine):
# # Ensure that cf-execd and cf-monitord are running # */5 * * * * root /usr/local/sbin/cfengine.sh runcheck
cfengine.tar.gz (2.2 MiB, 384 hits)