14
14
attr_accessor :source, :local
16
Copy a file over the current file. Uses `checksum` to
17
determine when a file should be copied. Valid values are either
18
fully qualified paths to files, or URIs. Currently supported URI
19
types are *puppet* and *file*.
21
This is one of the primary mechanisms for getting content into
22
applications that Puppet does not directly support and is very
23
useful for those configuration files that don't change much across
27
file { "/etc/mail/sendmail.cf":
28
source => "puppet://server/modules/module_name/sendmail.cf"
32
You can also leave out the server name, in which case `puppet agent`
33
will fill in the name of its configuration server and `puppet apply`
34
will use the local filesystem. This makes it easy to use the same
35
configuration in both local and centralized forms.
37
Currently, only the `puppet` scheme is supported for source
38
URL's. Puppet will connect to the file server running on
39
`server` to retrieve the contents of the file. If the
40
`server` part is empty, the behavior of the command-line
41
interpreter (`puppet apply`) and the client demon (`puppet agent`) differs
42
slightly: `apply` will look such a file up on the module path
43
on the local host, whereas `agent` will connect to the
44
puppet server that it received the manifest from.
46
See the [fileserver configuration documentation](http://docs.puppetlabs.com/guides/file_serving.html)
47
for information on how to configure and use file services within Puppet.
49
If you specify multiple file sources for a file, then the first
50
source that exists will be used. This allows you to specify
51
what amount to search paths for files:
53
file { "/path/to/my/file":
16
A source file, which will be copied into place on the local system.
17
Values can be URIs pointing to remote files, or fully qualified paths to
18
files available on the local system (including files on NFS shares or
19
Windows mapped drives). This attribute is mutually exclusive with
20
`content` and `target`.
22
The available URI schemes are *puppet* and *file*. *Puppet*
23
URIs will retrieve files from Puppet's built-in file server, and are
26
`puppet:///modules/name_of_module/filename`
28
This will fetch a file from a module on the puppet master (or from a
29
local module when using puppet apply). Given a `modulepath` of
30
`/etc/puppetlabs/puppet/modules`, the example above would resolve to
31
`/etc/puppetlabs/puppet/modules/name_of_module/files/filename`.
33
Unlike `content`, the `source` attribute can be used to recursively copy
34
directories if the `recurse` attribute is set to `true` or `remote`. If
35
a source directory contains symlinks, use the `links` attribute to
36
specify whether to recreate links or follow them.
38
Multiple `source` values can be specified as an array, and Puppet will
39
use the first source that exists. This can be used to serve different
40
files to different system types:
42
file { "/etc/nfs.conf":
55
"/modules/nfs/files/file.$host",
56
"/modules/nfs/files/file.$operatingsystem",
57
"/modules/nfs/files/file"
44
"puppet:///modules/nfs/conf.$host",
45
"puppet:///modules/nfs/conf.$operatingsystem",
46
"puppet:///modules/nfs/conf"
61
This will use the first found file as the source.
63
You cannot currently copy links using this mechanism; set `links`
64
to `follow` if any remote sources are links.
50
Alternately, when serving directories recursively, multiple sources can
51
be combined by setting the `sourceselect` attribute to `all`.
67
54
validate do |sources|