Forum: CFEngine Help
Subject: Defining default vars
Author: davidlee
Link to topic: https://cfengine.com/forum/read.php?3,23704,23704#msg-23704
I'm using 3.1.4 community.
Within a bundle, we are defining a lot of data into associative arrays, then
using those arrays in "files:", "methods:", etc. to drive certain actions.
Overall it is a clean structure. But it would be even cleaner if we could
somehow use default values under certain conditions. I'm thinking of something
like:
vars:
any::
v_1 string => "everywhere";
class_a:
v_1 string => "only if class_a applies";
class_b:
v_1 string => "only if class_b applies";
### Now want to define defaults for "index_2" and "index_3".
### Something like:
v_1 string => "default index_2"
if !isvariable("v_1");
v_1 string => "default index_3"
if !isvariable("v_1");
By the end of that "vars:" section, all indexes (index_1, index_2, index_3) for
the all the variables (v_1, etc.) should have been set up one way or another.
In our real cases, there is considerably more data than in the example above.
If this is not possible at 3.1.4, is it possible at later versions?
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine