On 04/06/2012 09:50, no-re...@cfengine.com wrote:
> If it's that same bug, try the workarounds I listed in the bug
> report: either hardcode the filename, or put an intermediate bundle
> in between. Pass the name as a variable to the interim bundle and let
> the interim bundle call your final bundle. In the final bundle you
> refer to the variable as $(interim.variable), which does work.

Not hardcoding the filename was one of my concerns, so I tried the
interim bundle, and it works (see below), so it's probably the same bug.

Is it in the roadmap for 3.4.0?

Ciao
-- bronto

body common control
{
  bundlesequence => { "test" } ;
  inputs => { "cfengine_stdlib.cf" } ;
  version => "test" ;
}

bundle agent test
{
  vars:
      "h"     string => "/var/cfengine/testfiles/hosts" ;

  methods:
    "hosts" usebundle => hosts("$(h)","$(sys.ipv4)") ;
}

bundle agent hosts(h,myip)
{
  vars:
      "filename" string => "$(h)" ;

  files:
    "$(h)"
      edit_line => fix_host_entries("$(myip)") ;
}

bundle edit_line fix_host_entries(myip)
{
  vars:
      "count" int => readstringarray("records",      # array to populate
                                     "$(hosts.filename)",  # file to read
                                     "\s*#[^\n]*?",  # match comments
                                     "\s+",          # match fields
                                     "1000",         # max entries
                                     "80000") ;      # max bytes

      "ip"             slist  => getindices("records") ;
      "ipclass[$(ip)]" string => canonify("$(ip)") ;


  reports:
    __debug__::
      "Read $(count) records from $(h)" ;
      "Address matched: $(ip)" ;
}
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to