Forum: CFEngine Help
Subject: Re: conditional setting of a variable
Author: mark
Link to topic: https://cfengine.com/forum/read.php?3,23180,23205#msg-23205
These solutions should certainly work. I can't specifically recall any bugs
relating to this, but we cover a lot of ground in a few releases. Runtime
conditions might be better modelled by this:
body common control
{
bundlesequence => { "test" };
}
bundle agent test
{
classes:
"runtime_condition" expression => fileexists("/tmp/bla");
"var_defined" expression => isvariable("conditional");
vars:
"foo" string => "bar";
runtime_condition::
"conditional" string => "this sometimes happens";
files:
"/tmp/bla"
create => "true";
reports:
cfengine_3::
"foo: $(foo)";
var_defined::
"conditional: $(conditional)";
}
In this case, the file actually gets created as part of the script. This
generates the expected result:
tlas$ ~/LapTop/cfengine/core/src/cf-agent -f ~/test.cf
R: foo: bar
R: conditional: this sometimes happens
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine