Forum: Cfengine Help Subject: Re: Cfengine3 / hierarchical copy Author: zzamboni Link to topic: https://cfengine.com/forum/read.php?3,17771,17967#msg-17967
Christian, I had seen the "Singlecopy Nirvana" page before and thought briefly about how to implement it for cf3, but your post gave me the push to actually implement and test it. It turns out with cf3 it's even easier, because you don't have to write all those copy statements, just define the list of suffixes in a variable and cf3 will automatically cycle through them. Here's my example code: # # Sample cf3 implementation of "single copy nirvana" from # http://cfwiki.org/cfwiki/index.php/Singlecopy_Nirvana # # Time-stamp: < modified by Diego Zamboni on Monday, 2010.08.23 at 01:44:19> # body common control { bundlesequence => { "copyfiles" }; } # Use single copy for all files body agent control { files_single_copy => { ".*" }; } ###################################################################### bundle agent copyfiles { vars: # Suffixes to try, in most-specific to most-general order. This must include the # empty suffix at the end, for the most general file. # In this example I'm taking them from the system variables, but they could # be anything. "copysuffixes" slist => { ".${sys.uqhost}", ".${sys.domain}", ".${sys.os}", "" }; # List of files to copy "filestocopy" slist => { "test1", "test2", "test3" }; # Source of the files "repo" string => "/tmp/testrepo"; # Destination for the files "dest" string => "/tmp/testdest"; files: "${dest}/${filestocopy}" copy_from => hierarchical_copy("${filestocopy}"); } body copy_from hierarchical_copy(from) { source => "${repo}/${from}${copysuffixes}"; compare => "digest"; } (Shameless plug: I also wrote about this in my blog: http://blog.zzamboni.org/implementing-single-copy-nirvana-in-cfengine3 ) --Diego _______________________________________________ Help-cfengine mailing list [email protected] https://cfengine.org/mailman/listinfo/help-cfengine
