Excluding Pathname Patterns in Copy
From Cfwiki
Following good configuration management practices, we keep our Cfengine repository in Subversion. A side effect is that our master location contains all these .svn directories with the Subversion meta-data inside them. This results in copy operations pulling the .svn directories and their contents to all the clients.
I had tried using the exclude command to filter out the .svn directories:
copy: $(master_cfinput) dest=$(workdir)/inputs r=inf mode=0644 type=binary server=$(policyhost) trustkey=true exclude=.svn # also tried .svn/* */.svn/* purge=true
However, I soon discovered that didn't work, based on this output (snippet):
Checking copy from cfengine.mycompany.net:/var/cfengine-repository/inputs to /var/cfengine/inputs [snip] Opening /var/cfengine-repository/inputs/.svn->/var/cfengine/inputs/.svn Opening /var/cfengine-repository/inputs/.svn/prop-base->/var/cfengine/inputs/.svn/prop-base cfengine:cftest: /var/cfengine/inputs/.svn/prop-base/cfagent.conf.svn-base wasn't at destination (copy ing) cfengine:cftest: Copying from cfengine.pd.qpass.net:/var/cfengine-repository/inputs/.svn/prop-base/cfa gent.conf.svn-base cfengine:cftest: Object /var/cfengine/inputs/.svn/prop-base/cfagent.conf.svn-base had permission 600, changed it to 644 cfengine:cftest: /var/cfengine/inputs/.svn/prop-base/cf.users.svn-base wasn't at destination (copying) cfengine:cftest: Copying from cfengine.pd.qpass.net:/var/cfengine-repository/inputs/.svn/prop-base/cf. users.svn-base cfengine:cftest: Object /var/cfengine/inputs/.svn/prop-base/cf.users.svn-base had permission 600, chan ged it to 644 [etc.]
...and surmised the exclude command only matches file names, not directories.
So after more experimenting, reading docs and searching around, I came across the filters action, and realized I could use it. After trying different approaches, I finally arrived at the result for which I was searching:
copy:
$(master_cfinput)
dest=$(workdir)/inputs
r=inf
mode=0644
type=binary
server=$(policyhost)
trustkey=true
filter=filter_no_svn_dirs
purge=true
filters:
{ filter_no_svn_dirs
NameRegex: ".*/\.svn(/.*)?$"
Result: "!NameRegex"
}
I can then use this filter in any subsequent copy action. I guess it would be nice to be able to define a global filter so I wouldn't have to do this, but I'm happy I have something that works.
Please post feedback if you enjoyed this article and found it useful.
Xqnstyl 18:08, 13 April 2007 (EDT)
See also ignore.
--Mwr 22:36, 22 April 2007 (EDT)
I found out that with this filter, directories are not copied, but subdirectories at the destination that do not exist at the source are still purged! I consider this a bug.
--Svenxy 07:47, 15 August 2007 (EDT)
