Well, after more digging. It seems readstringarray is reporting
correctly, as the file appears as it was before it was modified. I
hate to keep harping on this, but I don't understand why and I keep
running into roadblocks in this type of scenerio. For example:

body common control {

    bundlesequence => {"Step_1","Step_2"};

}

bundle agent Step_1  {

  files:

    "$(sys.workdir)/filename"
          copy_from     => server_copy("hosts,"$(global.default_server)");
          perms         => p("root","system","600"),
          action        => immediate;

}


bundle agent Step_2 {

  vars:
    "array"         int    =>
readstringarray("hosts","$(sys.workdir)/hosts","#[^\n]*",":",50,40000);
    "canon_host"    string => canonify("$(sys.fqhost)");

  classes:
    "host_not_found"        expression => islessthan("$(array)",1);

  files:

     host_not_found::
      "$(sys.workdir)/cf_hosts"
       create    => true,
       perms     => p("root","system","644"),
       edit_line => add_host("$(canon_host)");

}


Step_1: copies a file from the server and puts it in $(sys.workdir)/hosts.
Step_2: checks to see if the current host is in $(sys.workdir)/hosts,
and if not, set host_not_found class, add the host in.

The host does not exist on the server's copy of hosts. It is
downloaded and cf-agent adds the host in. Great. Perfect. Just the way
it should work.

Now the second run. readstringarray reads the hosts file, sees that
the host is in there (added from previous run), class host_not_found
is not set. Step_1 is run, new host file is downloaded, which does not
contain the host. Since host_not_found is not set, it is never added
it.

So basically is works 1/2 the time. Am I just a bad config writer and
doing things I shouldn't, or is this the way it supposed to work?



On Fri, Apr 24, 2009 at 8:09 AM, Matt Richards <[email protected]> wrote:
> I copied over evalfunction.c from svn (I cannot get cfengine to build
> from svn for some reason), and now the messages are:
>
> cf3 Could not read expected amount from file
> /var/opt/cfengine/cf_hosts in readfile
> cf3 (fread: Error 0)
>
> The question I have is - does readstringarray only run at the start of
> the cf-agent run during the variable convergence? Say, for example,
> the file that readstringarray changes during in other agent bundles,
> it seems that the readstringarray no longer relfects the correct
> values as it is only parse once during the start.
>
> On Thu, Apr 9, 2009 at 1:05 PM, Mark Burgess <[email protected]> wrote:
>>
>> Fixed in svn
>>
>> Matt Richards wrote:
>>> Here is an odd one. It seem like the file in readstringarray is
>>> checked right away, instead of waiting for bundle to resolve the
>>> parameter:
>>>
>>> ###
>>>
>>> bundle agent foo {
>>>
>>>      "/etc/foo"
>>>           edit_line => delete_users("$(sys.workdir)/userfile");
>>>
>>> }
>>>
>>> ###
>>> bundle edit_line delete_users(filename) {
>>>
>>>   vars:
>>>
>>>    "userarray"  int   =>
>>> readstringarray("users","$(filename)","#[^\n]*",":",100,40000);
>>>    "user_list"  slist => getindices("users");
>>>
>>>    delete_lines:
>>>      "^$(user_list):.*";
>>>
>>> }
>>>
>>> # cf-agent -Kv
>>>
>>> ...
>>>
>>> cf3 Could not examine file $(filename) in readfile
>>> cf3 (stat: No such file or directory)
>>> cf3 Could not examine file $(filename) in readfile
>>> cf3 (stat: No such file or directory)
>>> cf3 Initiate variable convergence...
>>> cf3 Could not examine file $(filename) in readfile
>>> cf3 (stat: No such file or directory)
>>> cf3 Initiate control variable converge
>>> _______________________________________________
>>> Bug-cfengine mailing list
>>> [email protected]
>>> https://cfengine.org/mailman/listinfo/bug-cfengine
>>
>> --
>> Mark Burgess
>>
>> -------------------------------------------------
>> Professor of Network and System Administration
>> Oslo University College, Norway
>>
>> Personal Web: http://www.iu.hio.no/~mark
>> Office Telf : +47 22453272
>> -------------------------------------------------
>>
>

_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to