--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.
Hi Merlin,
I don't think that you need copylink_patterns
, it defines a list of regular expressions matching files that should be copied instead of linked, which is the opposite of what you want.
There is also linkcopy_patterns
which is a list of regular expressions matching filenames that should be symlinked and not copied. You can use this to create a symlink mirror locally. Also not what you are looking for.
What version of CFEngine are you running? I am able to copy a file tree
recursively and preserve symlinks. Note that I am using depth_search
, and file_select
in my files
type promise to mirror the directory. Also I am only testing this locally, should be straight forward to convert into a remote copy.
mkdir -p /tmp/source/ echo "Hello world" > /tmp/source/file.txt cd /tmp/source ln -s file symlink ls -al /tmp/source
bundle agent main { files: "/tmp/dest/." create => "true"; "/tmp/dest/." copy_from => sync_including_symlinks( "/tmp/source/." ), depth_search => recurse(inf), # Search the entire directory tree down file_select => all, # Select all files move_obstructions => "true"; # Move things so you can ensure links # and dirs are proper mirrors reports: "CFEngine $(sys.cf_version)"; "$(with)" with => execresult( "ls -al /tmp/dest/", useshell); } body copy_from sync_including_symlinks( source_path ) { source => "$(source_path)"; compare => "digest"; verify => "true"; purge => "true"; copy_backup => "false"; # Don't make .cfsaved files # no-op when using TLS (3.7.0 and newer) # encrypt => "true"; # I am doing a local copy # servers => { "$(server)" }; } # Duplicated inline from the stdlib body file_select all # @brief Select all file system entries { leaf_name => { ".*" }; file_result => "leaf_name"; } body depth_search recurse(d) # @brief Search files and direcories recursively, up to the specified depth # Directories on different devices are included. # # @param d The maximum search depth { depth => "$(d)"; xdev => "true"; }
After running the policy we get a mirror that looks like this:
R: CFEngine 3.11.0 R: total 4568 drwxr-xr-x 2 nickanderson nickanderson 4096 Mar 23 08:02 . drwxrwxrwt+ 30 root root 4665344 Mar 23 08:05 .. -rw-rw-r-- 1 nickanderson nickanderson 12 Mar 23 08:02 file.txt lrwxrwxrwx 1 nickanderson nickanderson 8 Mar 23 08:02 symlink -> file.txt
–
Nick Anderson
Doer of things, CFEngine