Cfengine configuration directory

Copying named files to name locations (labelled dissemination)

Relevant classes: any

Suppose you have a centralized "master server" and you want to spread data to other locations, e.g. for diskless clients or virtual machine configuration. This is awkward in cfengine version 2. You would like to do this:
copy:

  # Suppose we have config.conf to copy to a list of named dirs

  # /path/config.conf dest=/diskless/$(hostlist)/config.conf

  # Suppose we have host1.conf, host2.conf to disseminate to different dirs

  # /path/$(hostlist).conf dest=/diskless/$(hostlist)/config.conf


However you can work around the problem my using methods.

Use a cfagent.conf entry on the master like this to collect a file from the list. We use list iteration to accomplish this.


control:

 Split = ( ":" )
 hostlist = ( "host1:host2:host3" )

methods:

  Disseminate("/path/$(hostlist).conf","/diskless/$(hostlist)/config.conf")

This results in a copying:

Disseminate ( /path/host1.conf, /diskless/host1/config.conf )
Disseminate ( /path/host2.conf, /diskless/host2/config.conf )
Disseminate ( /path/host3.conf, /diskless/host3/config.conf )

In other words, you can keep files named in a single master respository (under version control) and copy them into place in a single operation. This feature is available from version 2.2.2 Now you simply have to write a method
control:

 MethodName       = ( Disseminate )
 MethodParameters = ( from to )

 actionsequence = ( copy )

copy:

 $(from) dest=$(to)


Back to documentation