Forum: Cfengine Help
Subject: Re: Help editing /etc/hosts with cf3
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,17873,17875#msg-17875

How about this.  Boiled down it is a simple search and replace.

            "${g.crontabs}/root"
                create => "true",
                edit_line => del_insert_str(
                    "${cfexecd_cron_line}",
                    ".*?cf-execd.*"
                ),

####################
# file editing 
####################
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.";
}


bundle edit_line AppendIfNoLine(line) {
    insert_lines:
        "${line}" location => "append";
}

body location append {
    before_after => "after";
}


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

Reply via email to