Forum: CFEngine Help Subject: Re: conditional setting of a variable Author: neilhwatson Link to topic: https://cfengine.com/forum/read.php?3,23180,23200#msg-23200
Vars promises are before classes. I would expect that the variable would not be defined until the second run. However, the report is promised during the first run even without the variable defined. During the following second and third runs the reports promise has already been verified and is thus locked. So I think we are seeing expected behaviour however disappointing. If you use the isvariable function you can get around this. body common control { bundlesequence => { "test" }; } bundle agent test { classes: "runtime_condition" expression => fileexists("/etc/passwd"); "var_defined" expression => isvariable("conditional"); vars: "foo" string => "bar"; runtime_condition:: "conditional" string => "this sometimes happens"; reports: cfengine_3:: "foo: $(foo)"; var_defined:: "conditional: $(conditional)"; } neil@ettin ~/.cfagent/inputs $ cf-agent -IKf ./test.cf R: foo: bar R: conditional: this sometimes happens _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine