1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#########################################################################
#
# scheduling.cf - Command Execution Scheduling
#
# NOTE: Commands can be executed based on any class expression.
# Examples include execution of other commands (sequencing),
# time, OS, hostname or the outcome of another promise.
# If a shell wrapper is not needed, removing it will increase
# security and performance.
#
#########################################################################
body common control
{
bundlesequence => { "system_scheduling" };
inputs => { "$(sys.libdir)/stdlib.cf" };
}
bundle agent system_scheduling
{
vars:
# Command definitions are given in cmd[index].
# The dependencies of the commands are dep_cmd[index], as boolean class expressions.
# Comments are given as comment_cmd[index]
"cmd[1]" string => "$(sys.cf_key)";
"dep_cmd[1]" string => "cmd2_success";
"comment_cmd[1]" string => "Check that a Cfengine key is generated if command 2 has run (dummy)";
windows::
"cmd[2]" string => "\"$(sys.winsysdir)\shutdown.exe\" /r /c \"Cfengine automatic restart\" /t 120";
"dep_cmd[2]" string => "Monday.Hr05.Min00_05";
"comment_cmd[2]" string => "Restart windows every week";
"cmd[3]" string => "$(sys.winsysdir)\cscript.exe \"$(sys.workdir)\script1.vbs\" //Nologo > \"$(sys.workdir)\script1_out.txt\"";
"dep_cmd[3]" string => "Hr05.Min05_10";
"comment_cmd[3]" string => "Run a script and save its output for later reference (needs to be run in shell)";
!windows::
"cmd[2]" string => "/bin/echo Hello World!";
"dep_cmd[2]" string => "Hr12.Min00_05";
"comment_cmd[2]" string => "Print a message (dummy)";
any::
"cmd_index" slist => getindices("cmd");
commands:
# Runs a command if its dependencies are satisfied
"$(cmd[$(cmd_index)])"
classes => if_repaired("cmd$(cmd_index)_success"),
ifvarclass => "$(dep_cmd[$(cmd_index)])",
contain => in_shell,
comment => "$(comment_cmd[$(cmd_index)])";
}
|