body common control
{
bundlesequence => { "main", };
}
body agent control
{
default_repository => '/tmp/newatson-junk';
}
bundle agent main
{
files:
"/tmp/ssh_config"
create => 'true',
copy_from => local_cp( '/etc/ssh/ssh_config' );
}
body copy_from local_cp ( src )
{
source => ${src};
compare => 'digest';
use_default_repository::
copy_backup => 'timestamp';
}
https://docs.cfengine.com/latest/reference-promise-types-files.html#copy_backup
The reference does not specify what 'timestamp' means. My expected results:
1. Backups will be in the form of /tmp/newatson-junk/ssh_config.<some timestamp>.
2. Backups will not happen unless the class use_default_repository is true.
Now, let's test it on 3.6.5:
$ rm -fr /tmp/ssh_config /tmp/newatson-junk/
$ cf-agent -Kf ./
repo.cf
$ ls -ltr /tmp/ssh_config /tmp/newatson-junk/
-rw-r--r-- 1 newatson cad 2047 Jun 25 15:29 /tmp/ssh_config
/tmp/newatson-junk/:
total 0
-rw------- 1 newatson cad 0 Jun 25 15:29 _tmp_ssh_config_cfsaved
Low and behold, a backup that I did not ask for and is not timestamped.
Now, I'll edit /tmp/ssh_config to force a new promise repair and run
cf-agent again:
$ cf-agent -Kf ./
repo.cf
$ ls -ltr /tmp/ssh_config /tmp/newatson-junk/
-rw-r--r-- 1 newatson cad 2047 Jun 25 15:31 /tmp/ssh_config
/tmp/newatson-junk/:
total 4
-rw-r--r-- 1 newatson cad 668 Jun 25 15:31 _tmp_ssh_config_cfsaved
A new backup file, that I still did not ask for, and the old one is gone.
How is the default_repository and copy_backup supposed to work?
--
Neil H Watson
Sr. Partner, Architecture and Infrastructure
CFEngine reporting:
https://github.com/evolvethinking/delta_reporting
CFEngine policy:
https://github.com/evolvethinking/evolve_cfengine_freelib
CFEngine and vim:
https://github.com/neilhwatson/vim_cf3
CFEngine support:
http://evolvethinking.com