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 41 def initialize(name, path, source, ignore = nil, environment = nil, source_permissions = :ignore) 42 @name, @path, @source, @ignore, @environment, @source_permissions = name, path, source, ignore, environment, source_permissions 43 44 end
Public Instance Methods
catalog()
click to toggle source
# File lib/puppet/configurer/downloader.rb 55 def catalog 56 unless @catalog 57 @catalog = Puppet::Resource::Catalog.new("PluginSync", @environment) 58 @catalog.host_config = false 59 @catalog.add_resource(file) 60 end 61 @catalog 62 end
evaluate() { |resource| ... }
click to toggle source
Evaluate our download, returning the list of changed values.
# File lib/puppet/configurer/downloader.rb 9 def evaluate 10 Puppet.info _("Retrieving %{name}") % { name: name } 11 12 files = [] 13 begin 14 catalog.apply do |trans| 15 unless Puppet[:ignore_plugin_errors] 16 # Propagate the first failure associated with the transaction. The any_failed? 17 # method returns the first resource status that failed or nil, not a boolean. 18 first_failure = trans.any_failed? 19 if first_failure 20 event = (first_failure.events || []).first 21 detail = event ? event.message : 'unknown' 22 raise Puppet::Error.new(_("Failed to retrieve %{name}: %{detail}") % { name: name, detail: detail }) 23 end 24 end 25 26 trans.changed?.each do |resource| 27 yield resource if block_given? 28 files << resource[:path] 29 end 30 end 31 rescue Puppet::Error => detail 32 if Puppet[:ignore_plugin_errors] 33 Puppet.log_exception(detail, _("Could not retrieve %{name}: %{detail}") % { name: name, detail: detail }) 34 else 35 raise detail 36 end 37 end 38 files 39 end
file()
click to toggle source
# File lib/puppet/configurer/downloader.rb 46 def file 47 unless @file 48 args = default_arguments.merge(:path => path, :source => source) 49 args[:ignore] = ignore.split if ignore 50 @file = Puppet::Type.type(:file).new(args) 51 end 52 @file 53 end
Private Instance Methods
default_arguments()
click to toggle source
# File lib/puppet/configurer/downloader.rb 66 def default_arguments 67 defargs = { 68 :path => path, 69 :recurse => true, 70 :links => :follow, 71 :source => source, 72 :source_permissions => @source_permissions, 73 :tag => name, 74 :purge => true, 75 :force => true, 76 :backup => false, 77 :noop => false, 78 :max_files => -1 79 } 80 if !Puppet::Util::Platform.windows? 81 defargs[:owner] = Process.uid 82 defargs[:group] = Process.gid 83 end 84 return defargs 85 end