Forum: Cfengine Help
Subject: Re: Find Variable in File, Check and Replace
Author: Seva Gluschenko
Link to topic: https://cfengine.com/forum/read.php?3,17826,17827#msg-17827
Sure it is. Here is a sample promise (take into consideration that I'm not
looking into any real php.ini while writing this):
bundle agent php
{
files:
"/usr/local/etc/php.ini"
edit_line => mem_limit("35"),
comment => "Enforce memory limit";
}
bundle edit_line mem_limit(x)
{
classes:
"enforce" not => regline("mem_limit\s*=\s*$(x)", "$(edit.filename)");
delete_lines:
enforce::
"mem_limit\s*=.*" comment => "Remove unmatched value if any";
insert_lines:
enforce::
"mem_limit = $(x)" comment => "Add requested value";
}
Please note I'm not using replace_with here because a line might be not present
there at all.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine