Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I copy files to all clients using puppet? I have setup a puppet server and clients and I have tested the connection which was working fine. I am not a puppet expert, I am just a beginner, and I just want to know how to copy files to all clients from the puppet server? I also want to know how to delete files?

share|improve this question
From Jorge in chat: Copied the link in as an answer. – Rinzwind Sep 12 '11 at 16:58
up vote 7 down vote accepted

The Puppet File Server

This guide covers the use of Puppet’s file serving capability.

The puppet master service includes a file server for transferring static files. If a file resource declaration contains a puppet: URI in its source attribute, nodes will retrieve that file from the master’s file server:

# copy a remote file to /etc/sudoers
file { "/etc/sudoers":
    mode => 440,
    owner => root,
    group => root,
    source => "puppet:///modules/module_name/sudoers"

All puppet file server URIs are structured as follows:

puppet://{server hostname (optional)}/{mount point}/{remainder of path}

If a server hostname is omitted (i.e. puppet:///{mount point}/{path}; note the triple-slash), the URI will resolve to whichever server the evaluating node considers to be its master. As this makes manifest code more portable and reusable, hostnames should be omitted whenever possible.

The remainder of the puppet: URI maps to the server’s filesystem in one of two ways, depending on whether the files are provided by a module or exposed through a custom mount point.

Serving Module Files

As the vast majority of file serving should be done through modules, the Puppet file server provides a special and semi-magical mount point called modules, which is available by default. If a URI’s mount point is modules, Puppet will:

  • Interpret the next segment of the path as the name of a module…
  • ... locate that module in the server’s modulepath (as described here under “Module Lookup”...
  • ... and resolve the remainder of the path starting in that module’s files/ directory.
  • That is to say, if a module named test_module is installed in the central server’s /etc/puppet/modules directory, the following puppet: URI...


    ...will resolve to the following absolute path:


    If test_module was installed in /usr/share/puppet/modules, the same URI would instead resolve to:


Although no additional configuration is required to use the modules mount point, some access controls can be specified in the file server configuration by adding a [modules] configuration block; see Security.

Serving Files From Custom Mount Points

Puppet can also serve files from arbitrary mount points specified in the server’s file server configuration (see below). When serving files from a custom mount point, Puppet does not perform the additional URI abstraction used in the modules mount, and will resolve the path following the mount name as a simple directory structure.

File Server Configuration

The default location for the file server’s configuration data is /etc/puppet/fileserver.conf; this can be changed by passing the --fsconfig flag to puppet master.

The format of the fileserver.conf file is almost exactly like that of rsync, and roughly resembles an INI file:

    path /path/to/files
    allow *
    deny *

The following options can currently be specified for a given mount point:

  • The path to the mount’s location on the disk
  • Any number of allow directives
  • Any number of deny directives

path is the only required option, but since the default security configuration is to deny all access, a mount point with no allow directives would not be available to any nodes.

The path can contain any or all of %h, %H, and %d, which are dynamically replaced by the client’s hostname, its fully qualified domain name and its domain name, respectively. All are taken from the client’s SSL certificate (so be careful if you’ve got hostname/certname mismatches). This is useful in creating modules where files for each client are kept completely separately, e.g. for private ssh host keys. For example, with the configuration

   path /data/private/%h
   allow *

the request for file /private/file.txt from client will look for a file /data/private/client1/file.txt, while the same request from will try to retrieve the file /data/private/client2/file.txt on the fileserver.

Currently paths cannot contain trailing slashes or an error will result. Also take care that in puppet.conf you are not specifying directory locations that have trailing slashes.


Securing the Puppet file server consists of allowing and denying access (at varying levels of specificity) per mount point. Groups of nodes can be identified for permission or denial in three ways: by IP address, by name, or by a single global wildcard (*). Custom mount points default to denying all access.

In addition to custom mount points, there are two special mount points which can be managed with fileserver.conf: modules and plugins. Neither of these mount points should have a path option specified. The behavior of the modules mount point is described above under Serving Files From Custom Mount Points. The plugins mount is not a true mount point, but is rather a hook to allow fileserver.conf to specify which nodes are permitted to sync plugins from the Puppet Master. Both of these mount points exist by default, and both default to allowing all access; if any allow or deny directives are set for one of these special mounts, its security settings will behave like those of a normal mount (i.e., it will default to denying all access). Note that these are the only mount points for which deny * is not redundant.

If nodes are not connecting to the Puppet file server directly, e.g. using a reverse proxy and Mongrel (see Using Mongrel), then the file server will see all the connections as coming from the proxy server’s IP address rather than that of the Puppet Agent node. In this case, it is best to restrict access based on hostname. Additionally, the machine(s) acting as reverse proxy (usually will need to be allowed to access the applicable mount points.


More specific deny and allow statements take precedence over less specific statements; that is, an allow statement for would let it connect despite a deny statement for * At a given level of specificity, deny statements take precedence over allow statements.

Unpredictable behavior can result from mixing IP address directives with hostname and domain name directives, so try to avoid doing that. (Currently, if’s IP address is and fileserver.conf contains allow and deny, the IP-based allow directive will actually take precedence. This behavior may be changed in the future and should not be relied upon.)

Host Names

Host names can be specified using either a complete hostname, or specifying an entire domain using the * wildcard:

    path /export
    allow *

IP Addresses

IP address can be specified similarly to host names, using either complete IP addresses or wildcarded addresses. You can also use CIDR-style notation:

    path /export
    allow 192.168.0.*

Global allow

Specifying a single wildcard will let any node access a mount point:

    path /export
    allow *

Note that the default behavior for custom mount points is equivalent to deny *.

share|improve this answer
Hi @Rinzwind it will be nice if you add the exact answer what i want. – karthick87 Sep 13 '11 at 7:30
well the link from Jorge/this answer is the start to getting this done and it answers the question "How do I copy files to all clients using puppet?" including the security you should take into consideration. All it lacks is a method to remove files. I shall include that (the last bit of this answer is more about doing it securely might be better to remove it maybe). – Rinzwind Sep 13 '11 at 9:42
Do i want to edit manifests file? And enter the above lines ? – karthick87 Sep 13 '11 at 14:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.