Forum: CFEngine Help
Subject: Re: conditional setting of a variable
Author: davidlee
Link to topic: https://cfengine.com/forum/read.php?3,23180,23193#msg-23193
Thanks, Diego, particularly for the worked example.
It so happens that I had actually tried that approach, but it didn't seem to
work. So at that point so I then thought about var-class approach, but when I
couldn't get that to work either, I posted my message.
I've tried your example, as a straight cut-and-paste. For me, I get different
results: it fails whether or not the file exists:
==========
# ls -ld /tmp/foo
ls: /tmp/foo: No such file or directory
#
# cat /tmp/tdltest.cf
body common control
{
bundlesequence => { "test" };
}
bundle agent test
{
classes:
"runtime_condition" expression => fileexists("/tmp/foo");
vars:
"foo" string => "bar";
runtime_condition::
"conditional" string => "this sometimes happens";
reports:
cfengine_3::
"foo: $(foo)";
"conditional: $(conditional)";
}
#
# cf-agent -KI -f /tmp/tdltest.cf
R: foo: bar
R: conditional: $(conditional)
#
# touch /tmp/foo
# ls -ld /tmp/foo
-rw-r--r-- 1 root root 0 Aug 24 09:39 /tmp/foo
#
# cf-agent -KI -f /tmp/tdltest.cf
R: foo: bar
R: conditional: $(conditional)
#
#
==========
This is community edition 3.1.4 on RHEL 5.6.
Bug?
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine