Forum: CFEngine Help
Subject: conditional setting of a variable
Author: davidlee
Link to topic: https://cfengine.com/forum/read.php?3,23180,23180#msg-23180

(cfengine-community 3.1.4; RHEL 5.x)

Summary:  I would like to define a variable only if certain conditions, 
determined at run-time, are true.  But this doesn't seem possible.  Have I 
missed something?

Detail:

I'm setting up the data for an array, ultimately for a "key=value" formatted 
file, going via the recommended standard library and its "edit_line 
set_variable_values(v)".  The intuitive way would be:

============
class:
"runtime_condition" and => { ...foo ; bar ... };

vars:
v string => "always1";
v string => "always2";
v string => "sometimes1"
  ifvarclass => "runtime_condition";

============

That "ifvarclass" would be very nice, very intuitive and very clean.  But it 
doesn't work.

Calls where the run-time condition is true would get a three-element array 
corresponding to "index1", "index2" and "conditional1" and the file would get 
three "key=value" lines controlled by this.  Calls where it is false would get 
the two-element array corresponding just to "index1" and "index2" and the file 
would get just two "key=value" lines controlled by this.

For my current problem: have I missed something?

For the developers:   if this isn't currently possible in the intuitive way 
given above, could this enhancement be made in future versions?

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

Reply via email to