On 31/05/2012 20:48, no-re...@cfengine.com wrote:
> Marco, please look at my reply to your original message (which
> admittedly, I just posted, although I thought I had posted it way
> back then):
> https://cfengine.com/forum/read.php?3,26058,26098#msg-26098

:-D


> I haven't looked at your new bundles in detail, but I don't think you
> need to use readstringlist for this - you can just eliminate
> non-conformant records using a selective delete_lines pattern.

Well, my final policy has quite evolved and does much more than that:

- first, the file is "normalized" by eliminating whitespace before the
IP (if any), and separating the IP and the names with a TAB

- then, lines which contain our hostname but don't start with the right
address are deleted; note that we do this unconditionally, so it should
be equivalent to what you did in your sample policy

- then we insert our minimal set of records, but only if we think we
need to do so: this ensures that we avoid adding two times, say, the
same record but with a slightly different formatting (e.g.: because the
original record has tab-separated names instead of space-separated)

- then, finally, we fix our minimal set of records -- but only if they
were already there:
  + for 127.0.0.1, we ensure that the first entry is localhost, and
    we leave the rest untouched;
  + for ::1, we do the same
  + for our address, we check if the first name is our canonical name,
    if it's not, we "patch" the record; we may end up with our names
    added twice in the same line, but that's not a big deal.

So we do a pretty good job here, I think: we ensure that the good stuff
is there, we remove bad mistakes, and we patch lines that are almost OK,
keeping local customisations (if one adds more aliases to our hostname
other than the canonical name and the unqualified hostname, we don't
remove them).

What I really fail to understand is why the readstringarray function
doesn't fill out $(records) any more when I make the bundles parametric.
Can you reproduce that? Is it a because of a stupid mistake on my side?

Thanks a lot

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

Reply via email to