class Puppet::Configurer::Downloader

Attributes

ignore[R]
name[R]
path[R]
source[R]

Public Class Methods

new(name, path, source, ignore = nil, environment = nil, source_permissions = :ignore) click to toggle source
   # File lib/puppet/configurer/downloader.rb
40 def initialize(name, path, source, ignore = nil, environment = nil, source_permissions = :ignore)
41   @name, @path, @source, @ignore, @environment, @source_permissions = name, path, source, ignore, environment, source_permissions
42 
43 end

Public Instance Methods

catalog() click to toggle source
   # File lib/puppet/configurer/downloader.rb
54 def catalog
55   unless @catalog
56     @catalog = Puppet::Resource::Catalog.new("PluginSync", @environment)
57     @catalog.host_config = false
58     @catalog.add_resource(file)
59   end
60   @catalog
61 end
evaluate() { |resource| ... } click to toggle source

Evaluate our download, returning the list of changed values.

   # File lib/puppet/configurer/downloader.rb
 8 def evaluate
 9   Puppet.info _("Retrieving %{name}") % { name: name }
10 
11   files = []
12   begin
13     catalog.apply do |trans|
14       unless Puppet[:ignore_plugin_errors]
15         # Propagate the first failure associated with the transaction. The any_failed?
16         # method returns the first resource status that failed or nil, not a boolean.
17         first_failure = trans.any_failed?
18         if first_failure
19           event = (first_failure.events || []).first
20           detail = event ? event.message : 'unknown'
21           raise Puppet::Error.new(_("Failed to retrieve %{name}: %{detail}") % { name: name, detail: detail })
22         end
23       end
24 
25       trans.changed?.each do |resource|
26         yield resource if block_given?
27         files << resource[:path]
28       end
29     end
30   rescue Puppet::Error => detail
31     if Puppet[:ignore_plugin_errors]
32       Puppet.log_exception(detail, _("Could not retrieve %{name}: %{detail}") % { name: name, detail: detail })
33     else
34       raise detail
35     end
36   end
37   files
38 end
file() click to toggle source
   # File lib/puppet/configurer/downloader.rb
45 def file
46   unless @file
47     args = default_arguments.merge(:path => path, :source => source)
48     args[:ignore] = ignore.split if ignore
49     @file = Puppet::Type.type(:file).new(args)
50   end
51   @file
52 end

Private Instance Methods

default_arguments() click to toggle source
   # File lib/puppet/configurer/downloader.rb
65 def default_arguments
66   defargs = {
67     :path => path,
68     :recurse => true,
69     :links => :follow,
70     :source => source,
71     :source_permissions => @source_permissions,
72     :tag => name,
73     :purge => true,
74     :force => true,
75     :backup => false,
76     :noop => false,
77     :max_files => -1
78   }
79   if !Puppet::Util::Platform.windows?
80     defargs[:owner] = Process.uid
81     defargs[:group] = Process.gid
82   end
83   return defargs
84 end