~ubuntu-branches/ubuntu/quantal/puppet/quantal

« back to all changes in this revision

Viewing changes to lib/puppet/type/file.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-14 01:56:30 UTC
  • mfrom: (1.1.29) (3.1.43 sid)
  • Revision ID: package-import@ubuntu.com-20120714015630-ntj41rkvkq4zph4y
Tags: 2.7.18-1ubuntu1
* Resynchronise with Debian. (LP: #1023931) Remaining changes:
  - debian/puppetmaster-passenger.postinst: Make sure we error if puppet
    config print doesn't work
  - debian/puppetmaster-passenger.postinst: Ensure upgrades from
    <= 2.7.11-1 fixup passenger apache configuration.
* Dropped upstreamed patches:
  - debian/patches/CVE-2012-1906_CVE-2012-1986_to_CVE-2012-1989.patch
  - debian/patches/puppet-12844
  - debian/patches/2.7.17-Puppet-July-2012-CVE-fixes.patch
* Drop Build-Depends on ruby-rspec (in universe):
  - debian/control: remove ruby-rspec from Build-Depends
  - debian/patches/no-rspec.patch: make Rakefile work anyway if rspec
    isn't installed so we can use it in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
  include Puppet::Util::Backups
18
18
  include Puppet::Util::SymbolicFileMode
19
19
 
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.
25
 
 
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.
 
21
 
 
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.
 
25
 
 
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
    line endings.
30
32
 
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
37
39
  end
38
40
 
39
41
  newparam(:path) do
40
 
    desc "The path to the file to manage.  Must be fully qualified."
 
42
    desc <<-EOT
 
43
      The path to the file to manage.  Must be fully qualified.
 
44
 
 
45
      On Windows, the path should include the drive letter and should use `/` as
 
46
      the separator character (rather than `\\`).
 
47
    EOT
41
48
    isnamevar
42
49
 
43
50
    validate do |value|
191
198
  end
192
199
 
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)
201
210
  end
202
211
 
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:
 
215
 
 
216
      * `purge` subdirectories
 
217
      * Replace directories with files or links
 
218
      * Remove a directory when `ensure => absent`"
206
219
    newvalues(:true, :false)
207
220
    defaultto false
208
221
  end
235
248
  end
236
249
 
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.
243
 
 
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`.
 
253
 
 
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.
 
260
 
 
261
      If you have a filebucket configured, the purged files will be uploaded,
 
262
      but if you do not, this will destroy data."
246
263
 
247
264
    defaultto :false
248
265
 
251
268
 
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
258
 
      be used."
 
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."
259
276
 
260
277
    defaultto :first
261
278