Forum: CFEngine Help
Subject: Re: filecopy, transform with grep.
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,22985,23020#msg-23020

The postalias example is not really a good one in my opinion and causes the 
debate that we are now having.  Transformer operations are meant more for this 
type of thing.

# No syntax validation here.  Might not work but meaning is clear enough.
files:
    "/home/.*\.tar$"
        comment => "Find tar files files and compress.",
        transformer => "/usr/bin/gzip $(this.promiser)";

Above we instruct Cfengine to promise to compress all tar files found under 
/home.  That is the intend of the transformer: to perform the same operation on 
a collection of files. It is really an exception rather than the rule.  In most 
cases some sort of command promise is preferable.

The intent of the original grep promise is to promise the contents of the 
target file.  The grep command cannot really do it. If the file contain garbage 
it will still be garbage after the grep command. Cfengine can do better.  It 
can promise the exact contents of the target file.  It does this either by 
copying the desired file from a masterfiles location or by editing the file 
based on changes in the policy.

Yes, Cfengine is not aware of what postalias, or any transformer command does.  
It merely executes the command.  You might get warning or a promise failed if 
the return status is odd but that is the best you can hope for.

_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to