class Puppet::Configurer::Downloader

Attributes

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

Public Class Methods

new(name, path, source, ignore = nil, environment = nil) click to toggle source
# File lib/puppet/configurer/downloader.rb, line 28
def initialize(name, path, source, ignore = nil, environment = nil)
  @name, @path, @source, @ignore, @environment = name, path, source, ignore, environment
end

Public Instance Methods

catalog() click to toggle source
# File lib/puppet/configurer/downloader.rb, line 32
def catalog
  catalog = Puppet::Resource::Catalog.new
  catalog.host_config = false
  catalog.add_resource(file)
  catalog.environment = @environment
  catalog
end
evaluate() { |resource| ... } click to toggle source

Evaluate our download, returning the list of changed values.

# File lib/puppet/configurer/downloader.rb, line 8
def evaluate
  Puppet.info "Retrieving #{name}"

  files = []
  begin
    ::Timeout.timeout(Puppet[:configtimeout]) do
      catalog.apply do |trans|
        trans.changed?.find_all do |resource|
          yield resource if block_given?
          files << resource[:path]
        end
      end
    end
  rescue Puppet::Error, Timeout::Error => detail
    Puppet.log_exception(detail, "Could not retrieve #{name}: #{detail}")
  end

  files
end
file() click to toggle source
# File lib/puppet/configurer/downloader.rb, line 40
def file
  args = default_arguments.merge(:path => path, :source => source)
  args[:ignore] = ignore.split if ignore
  Puppet::Type.type(:file).new(args)
end