in puppet, ruby, software

Synchronization methods of a file with Puppet

Usually, to synchronize a file with remote hosts, using puppet, one would use the following pattern:

file { "/etc/init.d/pvfs2-server":
owner => root, group => root,
mode => 755,
source => "puppet:///files/pvfs2-server"
}

(using “source” to copy data as-is, and using “template(“filename”) to use a template structure as data).

Or, if one wishes to directly set the content of the target file:

file { "/etc/init.d/pvfs2-server":
owner => root, group => root,
mode => 755,
source => "puppet:///files/pvfs2-server"
}

Please note that on the first line, for example ‘file { “/etc/mpd.conf”:’), the “/etc/mpd.conf” is a merge of two functionalities/concepts: Usually, the syntax is clear and simple:

file { mon_fichier_mpd_conf:
path => "/etc/mpd.conf",
[...]
}

The first line is about the resource description. Its goal is to be able to reference to it a little later from another resources (Notify[], etc.). By putting directly the file path and name (I think it’s identified as a filename and not as a description because there are quotes, or maybe it’s because it begins with a slash?) you mege the “path” attribute with its description.
On the other end, we’ll not be able to reference to it later, if you need to.

You may also need to synchronize a file that is not present in the repository (puppet:///files/*). That usually happens, for example, when that file is regenerated by an external program or an external action (like /etc/passwd).

file {"/etc/passwd":
owner => root, group => root, mode => 644,
content => file("/etc/passwd")
}