File sweeps are searches through a directory tree in which many files are examined and considered for processing in some way. There are many instances where one uses cfengine to perform a file sweep.
files
action, for checking access rights and ownership
of files.
tidy
action, for checking files for deletion.
copy
action, while recursively checking whether to
copy a file tree.
The problem with file sweeps is that they can be too sweeping! Often you are not interested in examining every single file in a file tree. You might wish to perform a search
The tidy action is slightly different in this respect, since it
always expects to match a specific pattern. One is generally not interested
in a search which deletes everything except for a named pattern: this
would be too dangerous. For this reason, the syntax of tidy
is different and is documented in the section on tidying, See section tidy.
For file sweeps within files
and copy
you can specify
specific search parameters using the keywords include=
and exclude=
.
For example,
files: /usr/local/bin m=0755 exclude=*.ps action=fixall
In this example cfengine searches the entire file tree (omitting any directories listed in the ignore-list, See section ignore) and omitting any files ending in the extension `.ps'.
Specifying the include=
keyword is slightly different since it
automatically restricts the search to only named patterns, whenever
you have one or more instances of it. If you include patterns in this
way, cfengine ignores any files which do not match the given patterns.
It also ignores any patterns which you have specified in the global
ignore-list as well as patterns excluded with exclude=pattern
.
In other words, exclusions always override inclusions.
If you exclude a pattern or a directory and wish to treat it in some special way, you need to code an explicit check for that pattern as a separate entity. For example, to handle the exluded `.ps' files above, you would need to code something like this:
files: /usr/local/bin m=0644 include=*.ps action=fixall
Note: don't be tempted to enclose your wildcards in quotes. The quotes will be treated literally and the pattern might not match the way you would expect.
Go to the first, previous, next, last section, table of contents.