Make a list instead and pass it to the template, so that the recursion
takes place inside
edit_line => alledits("@(context.mylist)")
Jim Wight wrote:
> Can edit_line be used multiple times in the same files promise?
>
> Given the encouragement in the documentaion to create reusable templates, I
> expected it to be the case. However, given this input:
>
> body common control
> {
> bundlesequence => { "edit" };
> }
>
> bundle agent edit
> {
> files:
> "/tmp/editfile"
> create => "true",
> edit_defaults => EmptyFile,
> edit_line => InsertLine("Hello World"),
> edit_line => InsertLine("Goodbye World");
> }
>
> body edit_defaults EmptyFile
> {
> empty_file_before_editing => "true";
> }
>
> bundle edit_line InsertLine(line)
> {
> insert_lines:
> "$(line)";
> }
>
> cf-agent reports:
>
> cf3 .........................................................
> cf3 Promise: /tmp/editfile
> cf3 .........................................................
> cf3
> cf3 Build file model from a blank slate (emptying)
> cf3 Inconsistent edit_line constraints break this promise
> cf3 -> Handling file edits in edit_line bundle InsertLine
> cf3
> cf3 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> cf3 BUNDLE InsertLine( {'Goodbye World'} )
> cf3 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>
> and only inserts the second of the two lines (NB I know that both lines could
> be inserted via a single call of InsertLine with a multi-line string).
>
> I don't understand what 'Inconsistent edit_line constraints break this
> promise'
> is telling me.
>
> Jim
> _______________________________________________
> Bug-cfengine mailing list
> [email protected]
> https://cfengine.org/mailman/listinfo/bug-cfengine
--
Mark Burgess
-------------------------------------------------
Professor of Network and System Administration
Oslo University College, Norway
Personal Web: http://www.iu.hio.no/~mark
Office Telf : +47 22453272
-------------------------------------------------
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine