Forum: Cfengine Help
Subject: insert_type
Author: babudro
Link to topic: https://cfengine.com/forum/read.php?3,18780,18785#msg-18785
mark Wrote:
-------------------------------------------------------
> Try putting everything in one
> set of quotes
> and using
>
> insert_type => "preserve_block";
A question about this: The documentation says, "If the option ‘preserve_block’
is used, then Cfengine will not break up multiple lines into individual,
non-ordered objects, so that the block of text will be preserved." That sounds
as if the entire block gets treated as a single line and will give me the
desired result of preserving my formatting and keeping the file convergent.
However, the file is edited every time unless I do not empty it first. Exempli
gratia,
bundle agent testme {
files:
"/tmp/testme"
create => "true",
edit_line => testme,
edit_defaults => empty;
}
bundle edit_line testme {
insert_lines:
"# test me
# am I re-written every time?
",
insert_type => "preserve_block";
}
$ cf-agent -IKb testme -f ./promises.cf
>> Using command line specified bundlesequence
Edited file /tmp/testme
ababu...@rhtest2 Tue 2010-10-19 15:48:10 ADT
~/cfengine/masterfiles
$ cf-agent -IKb testme -f ./promises.cf
>> Using command line specified bundlesequence
Edited file /tmp/testme
ababu...@rhtest2 Tue 2010-10-19 15:48:14 ADT
~/cfengine/masterfiles
$
If I remove 'edit_defaults => empty' (using 'empty' from the COPBL) it is not
re-written, but then if text is changed the file grows rather than being
replaced. I changed one word in the second line and ended up with:
$ cat /tmp/testme
# test me
# am I re-written every time?
# test me
# am I re-written every other time?
If I remove 'insert_type => "preserve_block"' and leave 'edit_defaults =>
empty', then the file is not rewritten unless it changes.
Is this expected? If so, would you shed some light on it?
Thanks.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine