Forum: CFEngine Help
Subject: Re: Deleting extra entries inside config that's built by edit_line(s)
Author: terok
Link to topic: https://cfengine.com/forum/read.php?3,25689,25711#msg-25711

zzamboni Wrote:
-------------------------------------------------------
> Hi Tero,
> 
> You can use a delete_lines promise to do this.
> Below if the full example, but all that I added
> was this:
> 
>   delete_lines:
>       ".*"
>         select_region =>
> edit_in_between("^\[$(block)\]","^#\"),
>         delete_select =>
> not_starting_with("set_config_values_w_delim_and_b
> lock.index");
> 
> 
> and the corresponding delete_select body:
> 
> body delete_select not_starting_with(s)
> {
>         delete_if_not_startwith_from_list => {
> @(s) };
> }
> 
> 
> Best regards,
> --Diego

Excellent, thanks Diego! That did partly solve the problem and will mostly cover
my usecase, but it gets bit trickier :) 

Say that entire  gets removed from the promise (or some devious person
added new one to the config file manually). Now the delete_lines select_region
is set to use the block that we give it, but all passes will ignore everything
that's outside the promised block(s). 

This will leave me with invalid config. To possibly complicate things even
further with delete_lines, I can have same option = value entries in different
blocks.

/Tero

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

Reply via email to