17
17
include Puppet::Util::Backups
18
18
include Puppet::Util::SymbolicFileMode
20
@doc = "Manages local files, including setting ownership and
21
permissions, creation of both files and directories, and
22
retrieving entire files from remote servers. As Puppet matures, it
23
expected that the `file` resource will be used less and less to
24
manage content, and instead native resources will be used to do so.
26
If you find that you are often copying files in from a central
27
location, rather than using native resources, please contact
28
Puppet Labs and we can hopefully work with you to develop a
29
native resource to support what you are doing.
20
@doc = "Manages files, including their content, ownership, and permissions.
22
The `file` type can manage normal files, directories, and symlinks; the
23
type should be specified in the `ensure` attribute. Note that symlinks cannot
24
be managed on Windows systems.
26
File contents can be managed directly with the `content` attribute, or
27
downloaded from a remote source using the `source` attribute; the latter
28
can also be used to recursively serve directories (when the `recurse`
29
attribute is set to `true` or `local`). On Windows, note that file
30
contents are managed in binary mode; Puppet never automatically translates
31
33
**Autorequires:** If Puppet is managing the user or group that owns a
32
34
file, the file resource will autorequire them. If Puppet is managing any
40
desc "The path to the file to manage. Must be fully qualified."
43
The path to the file to manage. Must be fully qualified.
45
On Windows, the path should include the drive letter and should use `/` as
46
the separator character (rather than `\\`).
43
50
validate do |value|
193
200
newparam(:replace, :boolean => true) do
194
desc "Whether or not to replace a file that is
195
sourced but exists. This is useful for using file sources
196
purely for initialization."
201
desc "Whether to replace a file that already exists on the local system but
202
whose content doesn't match what the `source` or `content` attribute
203
specifies. Setting this to false allows file resources to initialize files
204
without overwriting future changes. Note that this only affects content;
205
Puppet will still manage ownership and permissions."
197
206
newvalues(:true, :false)
198
207
aliasvalue(:yes, :true)
199
208
aliasvalue(:no, :false)
203
212
newparam(:force, :boolean => true) do
204
desc "Force the file operation. Currently only used when replacing
205
directories with links."
213
desc "Perform the file operation even if it will destroy one or more directories.
214
You must use `force` in order to:
216
* `purge` subdirectories
217
* Replace directories with files or links
218
* Remove a directory when `ensure => absent`"
206
219
newvalues(:true, :false)
237
250
newparam(:purge, :boolean => true) do
238
desc "Whether unmanaged files should be purged. If you have a filebucket
239
configured the purged files will be uploaded, but if you do not,
240
this will destroy data. Only use this option for generated
241
files unless you really know what you are doing. This option only
242
makes sense when recursively managing directories.
244
Note that when using `purge` with `source`, Puppet will purge any files
245
that are not on the remote system."
251
desc "Whether unmanaged files should be purged. This option only makes
252
sense when managing directories with `recurse => true`.
254
* When recursively duplicating an entire directory with the `source`
255
attribute, `purge => true` will automatically purge any files
256
that are not in the source directory.
257
* When managing files in a directory as individual resources,
258
setting `purge => true` will purge any files that aren't being
259
specifically managed.
261
If you have a filebucket configured, the purged files will be uploaded,
262
but if you do not, this will destroy data."
252
269
newparam(:sourceselect) do
253
270
desc "Whether to copy all valid sources, or just the first one. This parameter
254
is only used in recursive copies; by default, the first valid source is the
255
only one used as a recursive source, but if this parameter is set to `all`,
256
then all valid sources will have all of their contents copied to the local host,
257
and for sources that have the same file, the source earlier in the list will
271
only affects recursive directory copies; by default, the first valid
272
source is the only one used, but if this parameter is set to `all`, then
273
all valid sources will have all of their contents copied to the local
274
system. If a given file exists in more than one source, the version from
275
the earliest source in the list will be used."