Forum: CFEngine Help
Subject: Re: Variable Class Names
Author: zzamboni
Link to topic: https://cfengine.com/forum/read.php?3,22838,22852#msg-22852

You need to use canonify, and then use the variable in a class expression. 
Canonify ensures that the string only has characters that are valid in class 
names. Using your example:

bunde agent my_app {
vars:
     "server_type" string => (read from file and it can be: db_server, 
app_server, dns_server, etc.);
     "c_server_type" string => canonify("${server_type}");

classes:
     "${c_server_type}" expression => "any";

files:
   db_server::
          "XXXXXXX"

   app_server::
          "XXXXXXX"

   dns_server::
          "XXXXXXX"

   etc..
}


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

Reply via email to