Forum: Cfengine Help
Subject: Re: importing tasks based on host group
Author: bbomgardner
Link to topic: https://cfengine.com/forum/read.php?3,20138,20144#msg-20144

One way to do this is to use methods. Here is some info from the reference 
guide:
http://www.cfengine.org/manuals/cf3-reference.html#promises_002ecf
http://www.cfengine.org/manuals/cf3-reference.html#methods-in-agent-promises

Also, here is a good thread discussing this:
https://cfengine.com/forum/read.php?3,19120,19130

I've found that Dan Klien's, er, method works well for me.  =)
A practice example:

body common control
{
  bundlesequence      =>      {
                                "blackout",
                                "global",
                                "cf_executor",
                                "cf_server",
                                "root_crontab",
                                "cf_tidy",
                                "resolv",
                                "machine_specific"
                              };
            
  inputs              =>      {
                                "cf-execd.cf",
                                "cf-serverd.cf",
                                "cf-agent.cf",
                                "cf-monitord.cf",
                                "cf-report.cf",
                                "cfengine_stdlib.cf",
                                "library.cf",
                                "root_crontab.cf",
                                "isp.cf",
                                "resolv.cf",
                                "oracle.cf",
                                "dist_ftp.cf"
                              };

}
#######################################################

bundle agent machine_specific
{
vars:

  "isp_seq" slist         =>  {
                                "isp_global",
                                "isp_jdk",
                                "isp_tomcat",
                                "isp_envs",
                                "isp_templates",
                                "isp_services"
                              };

  "dist_ftp_seq" slist    =>  {
                                "dist_ftp_pkgs",
                                "dist_ftp_conf"
                              };

methods:

  isp02|isp03::
    "any" usebundle     =>    "$(isp_seq)";

  ftp01::
    "any" usebundle     =>    "$(dist_ftp_seq)";

  oracle_servers::
    "any" usebundle     =>    "tnsnames";
}

#######################################################



Each policy file is imported on every host but not every bundle is executed. 
The 'machine_specific' bundle listed in the bundlesequence is run with the 
specific purpose of executing additional bundles as needed.

Its certainly a little less straightforward than using import in v2, but it 
works!  I hope this helps you.

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

Reply via email to