Neil,

That does seem to work, though I'm really hoping that it's working like Mark 
says and that the promises repaired percentage is fixed to reflect how it 
really works.

Here's what I have, based on your code:

bundle agent test {
    vars:
        "myfile" string => "/tmp/passwd_test";
        "valid_netgroups" slist => { "is", "dba" };

    files:
        "$(myfile)"
            edit_line => update_netgroups("@(test.valid_netgroups)");
}

bundle edit_line update_netgroups(valid_netgroups) {
    delete_lines:
        "\...@.*";

    insert_lines:
        "+...@$(valid_netgroups):x:::::";
}

Thanks!
Justin

-----Original Message-----
From: nwat...@symcor.com [mailto:nwat...@symcor.com] 
Sent: Thursday, February 11, 2010 11:00 AM
To: Justin Lloyd
Cc: help-cfengine@cfengine.org; help-cfengine-boun...@cfengine.org; Mark Burgess
Subject: RE: Deleting lines from a files that don't match a list

Try this.  It worked for me and only edited when necessary.

######################
body common control {
    bundlesequence => { "test" };
}

bundle agent test {

    vars:

        "ldaps" slist => {
            "+...@unix",
            "+...@ops"
        };

    files:

        "/tmp/edittest"
                edit_line => del_insert_str(
                    "@{test.ldaps}",
                    "....@.+"
                );
}

bundle edit_line del_insert_str(istr, dstr) {
# Replace one string with another by delete and insert.

    delete_lines:
        "${dstr}",
        comment => "Delete any instances of string/regex.";

    insert_lines:
        "${istr}",
        comment => "Insert one instance of string from.";
}


Sincerely,
--
Neil Watson
416-673-3465

This electronic communication and any attachments may contain confidential and 
proprietary 
information of DigitalGlobe, Inc. If you are not the intended recipient, or an 
agent or employee 
responsible for delivering this communication to the intended recipient, or if 
you have received 
this communication in error, please do not print, copy, retransmit, disseminate 
or 
otherwise use the information. Please indicate to the sender that you have 
received this 
communication in error, and delete the copy you received. DigitalGlobe reserves 
the 
right to monitor any electronic communication sent or received by its 
employees, agents 
or representatives.

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

Reply via email to