Forum: Cfengine Help
Subject: Re: dynamic classes using variables.
Author: sauer
Link to topic: https://cfengine.com/forum/read.php?3,22543,22609#msg-22609

To use the class to control reports, what you'd need to do is use the 
ifvarclass promise (which is available in all of agent's promise types), as in:

reports:
"yeah, this worked" ifvarclass => canonify("$(array_name[$(sys.host)][1])");


Otherwise, the code you have looks like it should work ok.  Though, note that 
you could also use the module protocol to do this pretty simply.  Something 
along the lines of this:

commands:
  "sed 's/#.*$//;s/^[[:space:]]*//;/^$/d;s/^/+/' 
$(sys.workdir)/inputs/hostclasses.csv" module => "true";

would also set a class for each line in the file after pruning characters after 
# and removing empty lines / leading whitespace.  It's not really "better" so 
much as "another way to do it" that seemed worth sharing. :)

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

Reply via email to