CORRECTION: I sent the wrong version of the config file.
/data/templates/copy_local_folder.cf
"#
# testing cfengine with following:
# copy local folder
#
body common control
{
bundlesequence => { "createFile" , "copyLocalFolder" };
ignore_missing_bundles => "true";
require_comments => "true";
inputs => {
"/var/cfengine/inputs/cfengine_stdlib.cf" };
version => "1.0";
}
body agent control
{
verbose => "true";
}
bundle agent createFile
{
files:
#
# the stanza below creates folders and file if it does not exist
#
"/data/test/create_folder1/create_file4.txt"
comment => "create file",
perms => mog("755", "root", "root"),
create => "true";
"/data/test/create_folder1/create_folder2/create_file5.txt"
comment => "create file",
perms => mog("755", "root", "root"),
create => "true";
"/data/test/create_folder1/create_folder3/create_file6.txt"
comment => "create file",
perms => mog("755", "root", "root"),
create => "true";
}
bundle agent copyLocalFolder
{
files:
"/data/test/create_folder1/copy_local_folder"
comment => "copy local folder",
include_dirs => { "/etc/cron.*" },
depth_search => recurse("inf"),
preserve => "true",
copy_from => local_cp("/etc");
}”
Regards,
j
*From:*Jerome Yanga
*Sent:* Friday, June 10, 2011 2:36 PM
*To:* 'Tokarski Boleslaw'
*Cc:* 'help-cfengine@cfengine.org'
*Subject:* RE: Cfengine Help: Copying Local Folder
Thanks, B. I was able to implement you suggestions....at least most
of it. I still have an issue though. The configuration below copies
all the /etc/cron* folders and files. However, it also copies all the
files in /etc/*. I tried testing with exclude_dirs but as its
description specifies, it only affects directories. Is there a way to
just copy /etc/cron*?
/data/templates/copy_local_folder.cf
“#
# testing cfengine with following:
# copy local folder
#
body common control
{
bundlesequence => { "createFile" , "copyLocalFolder" };
ignore_missing_bundles => "true";
require_comments => "true";
inputs => {
"/var/cfengine/inputs/cfengine_stdlib.cf" };
version => "1.0";
}
body agent control
{
verbose => "true";
}
bundle agent createFile
{
files:
#
# the stanza below creates folders and file if it does not exist
#
"/data/test/create_folder1/create_file4.txt"
comment => "create file",
perms => mog("755", "root", "root"),
create => "true";
"/data/test/create_folder1/create_folder2/create_file5.txt"
comment => "create file",
perms => mog("755", "root", "root"),
create => "true";
"/data/test/create_folder1/create_folder3/create_file6.txt"
comment => "create file",
perms => mog("755", "root", "root"),
create => "true";
}
bundle agent copyLocalFolder
{
files:
"/data/test/create_folder1/copy_local_folder"
comment => "copy local folder",
depth_search => recurse("inf"),
preserve => "true",
copy_from => local_cp("/etc/cron");
}"
Regards,
j
*From:*help-cfengine-boun...@cfengine.org
[mailto:help-cfengine-boun...@cfengine.org] *On Behalf Of *Tokarski
Boleslaw
*Sent:* Thursday, June 09, 2011 10:33 PM
*To:* help-cfengine@cfengine.org
*Subject:* Re: Cfengine Help: Copying Local Folder
Hello,
I would like to copy the folders /etc/cron* and its contents to
another location. However, I still end up copying the whole /etc
directory.
Well, this should be feasible :)
bundle agent copyLocalFolder
{
files:
"/tmp/test/create_folder1/copy_local_folder"
comment => "copy local folder",
preserve => "true",
depth_search => allofit("99999999999"),
exclude_dirs => { "*" },
include_dirs => { "cron" },
copy_from => myLocalCopy("/etc/.");
}
Looks wrong to me. Have a look at
http://www.cfengine.org/manuals/cf3-reference.html#Pattern-matching-and-referencing
The thing is you are using shell-type pattern * instead of
perl-compatible ones .*
Also this stanza looks pretty valid as to copy /etc directory to
/tmp/.../copy_local_folder. Did you mean to put something like
/etc/cron.*?
For depth_search you can use "inf", it's much better than specifying
any constant integer.
body depth_search allofit(d)
{
depth => "$(d)";
}
body copy_from myLocalCopy(from)
{
source => "$(from)";
}"
I saw you included cfengine_stdlib.cf. You can actually use
recurse(depth) and local_cp(from) body from there instead of rewriting
your own.
Best regards,
B