The important parts are :


1) '.*' anchored regexp in the files promise stops at the first '/' encountered, excluding '.' and '..'
2) ex_list body take @() syntax
3) we maintain the files we want in a convergent way with edit_line, and flush the others at the same FS level.

Further reading @cfengine.com


 bundle agent example(prefix,params)
{
vars:
"dest_dir" string => "/tmp";
"filenames" slist => { "file1", "fileN" };

files:
"$(dest_dir)/.*"
file_select => ex_list(@(filenames)),
delete => tidy;

"$(dest_dir)/$(filenames)"
create => "true",
edit_line => edit_whatever_body("$(prefix)","$(catalog)", "$(whatever_params)"),
edit_defaults => empty;

}

bundle edit_line edit_whatever_body(prefix,catalog,name)
{
insert_lines:
"# File Managed by CFEengine $(sys.cf_version)";
"$($(catalog)[$(name)][type]) $($(catalog)[$(name)][url]) $($(catalog)[$(name)][release]) $($(catalog)[$(name)][components])";
}