Forum: Cfengine Help
Subject: variable definition according to classes....
Author: bglomm
Link to topic: https://cfengine.com/forum/read.php?3,18697,18697#msg-18697

sorry this should be quite simple, still I seem to miss something :-/

I simply need to define two groups of hosts: "inhouse" and "outhouse".
Than a variable should be set according to the membership of the host...

This is what I tried:

bundle agent test {
vars:
  any::
   "outhouse_srv" slist => { "server1", "server2" };
   "inhouse_srv" slist => { "server3", "server4" };

  outhouse::
   "myvar" string => "abc";
  inhouse::   
   "myvar" string => "def";

classes:
   "outhouse" expression => reglist ("@(outhouse_srv)", "$(sys.host)");
   "inhouse" expression => reglist ("@(inhouse_srv)", "$(sys.host)");

files:
   "/tmp/foo"
   edit_line => append_if_no_line("$(myvar)");
}

runing cf-agent on host server3 now tells me:

---snipp--
vars in bundle test (1)
Skiping whole next promise (myvar), as context outhouse is not relevant
Skiping whole next promise (myvar), as context inhouse is not relevant

classes in bundle test (1)
+ Private classes augmented:
+ inhouse
- Private classes diminished:

files in bundle test (1)
...
?Augment scope append_if_no_line with str
 ?? Private class context
...
-> Inserting the promised line "$(myvar)" into /tmp/foo after locator
?? Private class context
....

--snapp--

now that ends in /tmp/foo having the string $(myvar) inserted not the value 
"def"


where do I go wrong? shouldn't it work like this? do I have to define a common 
bundle to define the classes before (hope not, should be possible to 
encapsulate this task injust one bundle)?

TIA

Bernhard

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to