Forum: Cfengine Help
Subject: Re: Force variables to be defined after classes?
Author: msvob...@linkedin.com
Link to topic: https://cfengine.com/forum/read.php?3,18656,18679#msg-18679

The example that prompted this thread to begin with in the first place...

vars:
     core_guppy::
        "machines_list"   slist   =>
                       { 
readstringlist("/var/cfengine/inputs/CoreGuppyMachines","#[^\n]*","[\n]",99999999,99999999)
 };
      db_guppy::
        "machines_list" slist   =>      
                      { 
readstringlist("/var/cfengine/inputs/DBGuppyMachines","#[^\n]*","[\n]",99999999,99999999)
 };
       app_guppy::
        "machines_list" slist   =>      
                      { 
readstringlist("/var/cfengine/inputs/AppGuppyMachines","#[^\n]*","[\n]",99999999,99999999)
 };

classes:
        "core_guppy"                    expression      =>
                
strcmp("$(restricted_policy_hostlist_file)","CoreGuppyMachines");
        "db_guppy"                      expression      =>
                strcmp("$(restricted_policy_hostlist_file)","DBGuppyMachines");
        "app_guppy"                     expression      =>
                strcmp("$(restricted_policy_hostlist_file)","AppGuppyMachines");


So I define classes based upon a keyword, and then read in separate files into 
a single slist variable array.

The workaround is to name each variable differently instead of trying to 
overload the same variable.  This also means that I populate the variable 
regardless if I am going to use it or not.

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

Reply via email to