linuxcfengine

Copying files among CFENGINE nodes


I am trying few features of CFENGINE 3.5 and stuck with a very basic issue. I want to copy certain files which are kept in cfengine Policy hub to various cfengine clients. These files are spread into various locations and further cfengine should copy these files to targeted machines on same location as master server has. How to do this ?


Solution

  • If you want to copy certain files from the hub onto the same location on the clients, you can do something like this:

    vars:
      "files" slist => { "/some/file", "/other/file", "/one/more/file" };
    
    files:
      "$(files)"
        copy_from => secure_cp("$(files)", "$(sys.policy_hub)");
    

    This will loop over the files, copying each one in turn. Make sure you include the appropriate standard library file to secure_cp(), something like this:

    body common control 
    {
      inputs => { "lib/3.5/files.cf" };
      bundlesequence => { ... };
    }