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
|
############################################################
#
# Keep a special promise only if at least n or m hosts
# keep a specific promise
#
# This method works with Enterprise CFEngine
#
# If you want to test this on localhost, just edit /etc/hosts
# to add host1 host2 host3 host4 as aliases to localhost
#
############################################################
body common control
{
bundlesequence => { "n_of_m_symphony" };
inputs => { "$(sys.libdir)/stdlib.cf" };
}
############################################################
bundle agent n_of_m_symphony
{
vars:
"count_compliant_hosts" string => hubknowledge("running_myprocess");
classes:
"reboot" expression => isgreaterthan("$(count_compliant_hosts)","20");
processes:
"myprocess"
comment => "Count this host if a job is matched",
classes => enumerate("running_myprocess");
commands:
reboot::
"/bin/shutdown now";
}
#######################################################
bundle server access_rules()
{
access:
"value of my test_scalar, can expand variables here - $(sys.host)"
handle => "test_scalar",
comment => "Grant access to contents of test_scalar VAR",
resource_type => "literal",
admit => { "127.0.0.1" };
"running_myprocess"
resource_type => "variable",
admit => { "127.0.0.1" };
}
|