Copy single files

Table of Contents

This is a standalone policy example that will copy single files, locally (local_cp) and from a remote site (secure_cp). The CFEngine Standard Library (cfengine_stdlib.cf) should be included in the /var/cfengine/inputs/libraries/ directory and inputs list as below.

body common control
{
      bundlesequence  => { "mycopy" };
      inputs => { "libraries/cfengine_stdlib.cf" };
}

bundle agent mycopy
{
  files:
      "/tmp/test_plain"

Path and name of the file we wish to copy to

      comment => "/tmp/test_plain promises to be an up-to-date copy of /bin/echo to demonstrate copying a local file",
      copy_from => local_cp("$(sys.workdir)/bin/file");

Copy locally from path/filename

      "/tmp/test_remote_plain"
      comment => "/tmp/test_plain_remote promises to be a copy of cfengine://serverhost.example.org/repo/config-files/motd",
      copy_from => secure_cp("/repo/config-files/motd", "serverhost.example.org");
}

Copy remotely from path/filename and specified host ```

This policy can be found in /var/cfengine/share/doc/examples/copy_copbl.cf and downloaded directly from github.