Excluding files in CFEngine copies

I frequently encounter people trying to do a recursive copy with CFEngine, but want to ignore some subdirectories or files.

A typical example is that /var/cfengine/masterfiles is under version control on the policy server, and a lot of meta-data is copied down to the clients during policy updates. Fortunately, it is very easy to ignore certain subdirectories during copies with CFEngine. Consider the following example.

bundle agent test_copy

copy_from => local_cp(“/tmp/src”),
depth_search => recurse_ignore(“inf”, “.svn”);

This will copy everything recursively, except the Subversion meta-directories. A self-contained example is available for download.

A sample run is shown below.

$ find /tmp/src/

$ cf-agent -KIf ./nosvn.cf

-> Copying from localhost:/tmp/src/subdir/file3
-> Copying from localhost:/tmp/src/file2
-> Copying from localhost:/tmp/src/file1

$ find /tmp/dest/

Of course, this can be integrated into your update.cf in order to avoid getting those pesky .svn directories everywhere.

Happy hacking!

This entry was posted in CFEngine and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>