This code works very well for a single line, ie:
edit_line => del_insert_str("10.1.1.4 myserver", "10\.1\.1\.4.*");
How might one add multiple host lines? I unsuccessfully tried giving multiple
edit_line statements, eg, the line above, plus:
Edit_line => del_insert_str("10.1.1.5 otherserver", "10\.1\.1\.5.*");
RCA
--
UNIX Administrator, BAE Systems EIT
desk 763-572-6684 mobile 612-419-9362
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of [email protected]
Sent: Tuesday, August 10, 2010 12:12 PM
To: [email protected]
Subject: Cfengine Help: Re: Help editing /etc/hosts with cf3
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
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine