Forum: CFEngine Help
Subject: Re: cf3 inputs, branching, selectiveness, staying sane
Author: simonblake
Link to topic: https://cfengine.com/forum/read.php?3,23400,23402#msg-23402

Hi Geoff

It bothered me that the default approach seemed to be load all inputs on all 
clients and then pick the relevant promises out at runtime - it seemed like a 
waste of cpu time parsing all the .cf files every run, and makes for much 
longer logs full of "promise foo not relevant".  

I wanted to have some promises common to all hosts, then some variable 
promises/inputs based on the role of the host, and then a few tidyup promises 
at the end.  To make each client only run the relevant inputs and promises, I 
do something like below.  The only caveat is that this has to be in promises.cf 
- setting inputs in other .cf files doesn't work (not unreasonably).  

body common control {
  bundlesequence => { 
   ....
    # Site specific stuff
    @(g.allbase), @(g.rolebase), @(g.tidyupbase)
  };

  inputs => {
    "update.cf",
    "cfengine_stdlib.cf",
    "cf-serverd.cf",
    "cf-execd.cf",
    # Site specific stuff 
    @(g.allinputs), @(g.roleinputs), @(g.tidyupinputs)
  };
}

bundle common g {
vars:

  "allinputs" slist  => { "site/resolv.cf", "site/all-common.cf",  
"site/collectd.cf" };
  "allbase"   slist  => { "unattendedupgrades", "timezone", "basepackages", 
"collectd" };

  "mysqlinputs"  slist  => { "site/mysql.cf" };
  "mysqlbase"    slist  => { "mysql", "mysql_check_root" };

  "tidyupinputs" slist  => { "site/restart.cf" };
  "tidyupbase"   slist  => { "restart" };

dnsmaster::
  "roleinputs" slist => { @(mysqlinputs), "site/pdns-mysql.cf", "site/pdns.cf", 
"site/pdns-admin.cf", "site/apache.cf" };
  "rolebase"   slist => { @(mysqlbase), "apache", "pdns_mysql", "pdns", 
"pdns_admin" };

dnsslave::
  "roleinputs" slist => { @(mysqlinputs), "site/pdns-mysql.cf", 
"site/openvz-ve.cf", "site/pdns.cf" };
  "rolebase"   slist => { @(mysqlbase), "openvz_ve", "pdns_mysql", "pdns" };

nms::
  "roleinputs" slist => { "site/apache.cf", "site/collection.cf" };
  "rolebase"   slist => { "apache", "collection" };

classes:

  # set classes based on hostname:
  "dnsmaster"   or => { "ns0" };
  "dnsslave"    or => { "ns1", "ns2", "ns3" };
  "nms"         or => { "nms1" };

}

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to