Forum: CFEngine Help Subject: Re: Append the content of file to another one without checking for duplicate lines Author: zzamboni Link to topic: https://cfengine.com/forum/read.php?3,26695,26700#msg-26700
I think CFEngine resists doing this because it makes it impossible to assure convergence. If you have a promise that appends a file to another without any checks, it will be appended every time the promise runs. There is no way to guarantee that it will ever reach a stable situation. One way to do this would be with a transformer attribute. This works: "/tmp/bigfile" create => "true", transformer => "/usr/bin/perl -e 'BEGIN { open(F1, q(>$(this.promiser))) } while() { print F2 $_ }'"; Note that transformer runs the command without a shell, so you can't simply use "cat /tmp/bigdata >> $(this.promiser)". I used a perl one-liner, but it could be anything else that performs the append on the file. This runs very quickly: $ /usr/bin/time cf-agent -K -f ./test-insertfile.cf 0.15 real 0.10 user 0.02 sys _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine