Don't mess vars and classes and, perhaps, read the Cfengine reference
more thoroughly. Brief rules are:

1. Variables can be accessed outside a bundle by bundle name, e.g.
$(bundle_name.variable_name)
2. Lists cannot be accessed outside a bundle directly and should be
reinstated locally, e.g.

vars:
    "local_list"  slist => { @(outer.list) };

3. Classes only become global being defined either in common bundles
or in compound bodies, e.g.

bundle common foo
{
  classes:
     "global_class" or => { "any" };
}

bundle agent bar
{
 files:
    "/tmp/foo"
         create => "true",
         classes => if_repaired("foo_done");
}

# defined in cfengine_stdlib.cf
body classes if_repaired(x)
{
  promise_repaired => { "$(x) };
}

2010/11/16 Gusto <gustofw...@gmail.com>:
> Hi Folks,
>
> It would seem that if you have one item in a slist it negates the vars.
>   "master_test" string => "/var/cfmasterfiles/cf310dev/test/";
>   "master_server" string => "tester.server.com";
>
> Idea was to add more servers as they where defined.
>
> Any thoughts?
>
> Regards,
> Gusto
>
> On Tue, Nov 16, 2010 at 12:11 PM, Gusto <gustofw...@gmail.com> wrote:
>> Hi Folks,
>>
>> I am seeing this behavior on the the 3.1.0 release, where if I define
>> in a bundle some variables I can not use them later on in the same
>> bundle. The normal order should be vars then later the files right?
>> This might have been discussed on another thread that I missed --
>> tried to follow as many as possible. Has anyone seen this issue, or a
>> solution?
>>
>> Any pointer are greatly appreciated
>> Best regards,
>> Gusto
>>
>>
>> Details:
>>  OS: Centos 5.5 x86_64
>>  Cfengine: gnu build in RPM version 3.1.0 final tar file.
>>  Use Case: I define in a agent bundle under vars the paths and server
>> strings/string lists for the paths and servers. This could be
>> something like your update.cf or just your failsafe.cf. When I run the
>> bundle does not see them. I had used this for my 3.0.5p1 configs (rpms
>> built on same server just release changed). During the beta I thought
>> this might have been the issue Neil spotted (
>> https://cfengine.com/bugtracker/view.php?id=334 ).
>>
>> I took a copy of the unit_server_copy_remote.cf and added the vars to
>> show what I see.
>>
>> NOTE: tester.server.com is defined as my network cf3 server. To
>> simplify this host is also acting as the server so there is no key
>> exchange complications.
>> ##### ---------------------- Sample from the unit_test modified to
>> show issue ---------------------------
>> body common control
>>   {
>>      bundlesequence  => {
>>                         "testbundle"
>>                         };
>>   }
>>
>> ############################################
>> bundle agent testbundle
>> {
>>
>> vars:
>>   linux::
>>    "master_test" string => "/var/cfmasterfiles/cf310dev/test/";
>>    "master_server" slist => { "tester.server.com" };
>>
>> classes:
>>    "testdir" expression => isdir("/tmp/testcf310");
>>
>> files:
>>  testdir::
>>    "/tmp/testcf310/somesample.txt"
>>       perms => system,
>>       copy_from =>
>> mycopy("$(master_server)/somesample.txt","$(master_server)"), #Does
>> not show all vars expanded.
>>       #copy_from =>
>> mycopy("$(master_server)/somesample.txt","tester.server.com"), #Does
>> not show all vars expanded.
>>       #copy_from =>
>> mycopy("/var/cfmasterfiles/cf310dev/test/somesample.txt","tester.server.com"),
>> #only way to get a copy moving.
>>       depth_search => recurse("inf"),
>>       classes  => repaired("got_somesample");
>>
>> reports:
>>   testdir::
>>    "The test dir is there and we have that class";
>>
>>   got_somesample::
>>    "Got the sample file";
>> }
>>
>> ############################################
>> body perms system
>> {
>> mode  => "0444";
>> }
>> #########################################################
>> body depth_search recurse(d)
>> {
>> depth => "$(d)";
>> }
>>
>> #########################################################
>> body classes repaired(class)
>> {
>>  promise_repaired => { "$(class)" };
>> }
>>
>> #########################################################
>> body copy_from mycopy(from,server)
>> {
>> source      => "$(from)";
>> #portnumber => "6789";
>> servers     => { "$(server)" , "failover1" };
>> copy_backup => "true";                   #/false/timestamp
>> stealth     => "true";                   #/on/false/off
>> preserve    => "true";
>> linkcopy_patterns => { ".*fish.*" };
>> copylink_patterns => { "non-local.*"};
>> xdev        => "true";                   # /on/false/off
>> compare     => "mtime";                  #
>> ctime/mtime/checksum/sum/byte/binary/any
>> link_type    => "absolute";              # /symbolic/relative/hard etc
>> type_check   => "true";
>> force_update => "false";
>> force_ipv4   => "false";
>> copy_size        => irange("0","50000");
>> trustkey    => "true";
>> encrypt     => "true";
>> verify      => "true";
>> #purge       => "false";
>> purge       => "true";
>> #findertype  => "MacOSX";
>> }
>> ##### --------------------- Sample End ---------------------------
>>
>> Running in debug 1 I see this:
>>
>> Matched syntatically correct bundle (lval,rval) item = (perms) to its rval
>> Constraint syntax ok, but definition of body is elsewhere perms=s
>> Prepending scalar to rval-list [system]
>> CopyRvalItem(s)
>>   Appending Constraint: perms => system
>> Recorded LVAL copy_from
>> Found function identifier mycopy
>> Start FnCall mycopy args level 1
>> Appending scalar to rval-list [ $(master_server)/somesample.txt]
>> CopyRvalItem(s)
>> Appending scalar to rval-list [$(master_server)]
>> CopyRvalItem(s)
>> End args level 1
>> Installing Function Call mycopy
>> Installed mycopy( $(master_server)/somesample.txt,$(master_server),)
>> om,)
>>
>> Running the server binary manually in foreground and with verbose I
>> also only see this connection when I don't use variables.
>>
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>



-- 
SY, Seva Gluschenko.
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to