On Wed, 14 Dec 2011 14:54:02 +0000 (GMT) Mark Dixon <[email protected]>
wrote:
MD> How would you cleanly do an if..elif..else ? The example you give
MD> appears to be an if..else.
cfengine doesn't have that. It has a switch statement, really, but it
will spin through the switch until it's settled (up to 3 passes I
think). Run cf-agent with -v and watch how it evaluates the conditions
on each pass.
MD> What I'm trying to avoid is the situation, like in the example below,
MD> where the "no_file_exists" class expression has to be rewritten
MD> everytime I need to test for another file:
I understand. Try this, I think it will do what you want.
Ted
#+begin_src cfengine3
body common control
{
bundlesequence => { "g" };
}
bundle common g
{
classes:
"my_file_exists" expression => fileexists("/myfile");
"your_file_exists" expression => fileexists("/yourfile");
vars:
any::
"root" string => "myroot3", policy => "overridable";
my_file_exists::
"root" string => "myroot1", policy => "overridable";
your_file_exists::
"root" string => "myroot2", policy => "overridable";
reports:
agent:: # note you can't use "any" class in reports
"Root is $(root)";
}
#+end_src
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine