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
{
files:“/tmp/dest”
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/
/tmp/src/
/tmp/src/subdir
/tmp/src/subdir/file3
/tmp/src/subdir/.svn
/tmp/src/file2
/tmp/src/.svn
/tmp/src/file1$ 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/
/tmp/dest/
/tmp/dest/subdir
/tmp/dest/subdir/file3
/tmp/dest/file2
/tmp/dest/file1
Of course, this can be integrated into your update.cf in order to avoid getting those pesky .svn directories everywhere.
Happy hacking!