Class: Puppet::Configurer::Downloader
- Defined in:
- lib/puppet/configurer/downloader.rb
Instance Attribute Summary collapse
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #catalog ⇒ Object
-
#evaluate ⇒ Object
Evaluate our download, returning the list of changed values.
- #file ⇒ Object
-
#initialize(name, path, source, ignore = nil, environment = nil, source_permissions = :ignore) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(name, path, source, ignore = nil, environment = nil, source_permissions = :ignore) ⇒ Downloader
Returns a new instance of Downloader.
42 43 44 45 46 47 48 49 |
# File 'lib/puppet/configurer/downloader.rb', line 42 def initialize(name, path, source, ignore = nil, environment = nil, = :ignore) @name = name @path = path @source = source @ignore = ignore @environment = environment @source_permissions = end |
Instance Attribute Details
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
7 8 9 |
# File 'lib/puppet/configurer/downloader.rb', line 7 def ignore @ignore end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/puppet/configurer/downloader.rb', line 7 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/puppet/configurer/downloader.rb', line 7 def path @path end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/puppet/configurer/downloader.rb', line 7 def source @source end |
Instance Method Details
#catalog ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/puppet/configurer/downloader.rb', line 60 def catalog unless @catalog @catalog = Puppet::Resource::Catalog.new("PluginSync", @environment) @catalog.host_config = false @catalog.add_resource(file) end @catalog end |
#evaluate ⇒ Object
Evaluate our download, returning the list of changed values.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet/configurer/downloader.rb', line 10 def evaluate Puppet.info _("Retrieving %{name}") % { name: name } files = [] begin catalog.apply do |trans| unless Puppet[:ignore_plugin_errors] # Propagate the first failure associated with the transaction. The any_failed? # method returns the first resource status that failed or nil, not a boolean. first_failure = trans.any_failed? if first_failure event = (first_failure.events || []).first detail = event ? event. : 'unknown' raise Puppet::Error, _("Failed to retrieve %{name}: %{detail}") % { name: name, detail: detail } end end trans.changed?.each do |resource| yield resource if block_given? files << resource[:path] end end rescue Puppet::Error => detail if Puppet[:ignore_plugin_errors] Puppet.log_exception(detail, _("Could not retrieve %{name}: %{detail}") % { name: name, detail: detail }) else raise detail end end files end |