Forum: Cfengine Help
Subject: Re: Delete_lines processed, but not insert_lines?
Author: Seva Gluschenko
Link to topic: https://cfengine.com/forum/read.php?3,20432,20434#msg-20434
mark Wrote:
-------------------------------------------------------
> If this is only one host, what makes you suspect
> something wrong with Cfengine?
Concurrent Cfengine runs may well happen on the single host, that's why. I'd
faced such kind of faults from time to time before I concluded that classes
must be defined to prevent multiple cf-agents from doing the same file. Did I
tell you already that edit_line bundle should lock the whole file, not just
single promises from a bundle, or was it discussed for emptying file only?
Anyway, it should.
Now, Mr. Gardner, you can either use empty_file_before_editing and fill it from
scratch, or define some classes to prevent concurrent runs, e.g.:
bundle edit_line resolv_config(search,list)
{
classes:
"search_list_empty" not => regcmp("search.*", "$(edit.filename)");
"nameservers_list_empty" not => regcmp("nameserver.*", "$(edit.filename)");
delete_lines:
!hpux::
"search.*" comment => "Reset search lines from resolver",
classes => if_repaired("search_list_empty");
hpux::
"domain.*" comment => "Reset domain lines from resolver",
classes => if_repaired("search_list_empty");
any::
"nameserver.*" comment => "Reset nameservers in resolver",
classes =>
if_repaired("nameservers_list_empty");
insert_lines:
!hpux.search_list_empty::
"search $(search)" comment => "Add search domains to resolver";
hpux.search_list_empty::
"domain $(search)" comment => "Add search domains to resolver";
nameservers_list_empty::
"nameserver $(list)" comment => "Add name servers to resolver";
}
While the code above lacks simplicity, it is a bit more safe.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine