deployment_scripts/puppet/modules/plugin_module/lib/puppet/type/override_resources.rb
# The main method of this metatype. Updates the existing resources
# according to the configuration, and, if crete is enabled,
# returns the array of the new resources that should be added to
# the catalog.
# @return [Array<Puppet::Type>]
The main method of this metatype. Updates the existing resources
according to the configuration, and, if crete is enabled,
returns the array of the new resources that should be added to
the catalog.
The main method of this metatype . Updates the existing resources according to the configuration and if crete is enabled returns the array of the new resources that should be added to the catalog .
def eval_generate
    new_resources = []
    configuration.each do |type, resources|
      fail "The 'type' should be the name of the Puppet type and not be empty! Got: #{type.inspect}" unless type and not type.empty?
      fail "The 'resources' should be a hash with the override Puppet resources! Got: #{resources.inspect}" unless resources.is_a? Hash
      next unless type_enabled? type
      debug "Processing type: #{type}"
      resources.each do |title, parameters|
        fail "The 'title' should be the title of the Puppet resource nd should not be empty! Got: #{title.inspect}" unless title and not title.empty?
        fail "The 'parameters' should be a hash of the resource parameters! Got: #{parameters.inspect}" unless parameters.is_a? Hash
        next unless title_enabled? title
        debug "Processing resource: #{type}[#{title}]"
        parameters = defaults_for(type).merge parameters
        if resource_present? type, title
          debug "#{type.capitalize}[#{title}] was found in the catalog, updating it!"
          update_resource type, title, parameters
        else
          if type_create? type or title_create? title
            debug "#{type.capitalize}[#{title}] was not found in the catalog, creating it!"
            new_resources << create_resource(type, title, parameters)
          else
            debug "#{type.capitalize}[#{title}] was not found in the catalog, skipping it!"
            next
          end
        end
      end
    end
    new_resources
  end
def eval_generate new_resources = [ ] configuration . each do | type , resources | fail "The 'type' should be the name of the Puppet type and not be empty! Got: #{type.inspect}" unless type and not type . empty? fail "The 'resources' should be a hash with the override Puppet resources! Got: #{resources.inspect}" unless resources . is_a? Hash next unless type_enabled? type debug "Processing type: #{type}" resources . each do | title , parameters | fail "The 'title' should be the title of the Puppet resource nd should not be empty! Got: #{title.inspect}" unless title and not title . empty? fail "The 'parameters' should be a hash of the resource parameters! Got: #{parameters.inspect}" unless parameters . is_a? Hash next unless title_enabled? title debug "Processing resource: #{type}[#{title}]" parameters = defaults_for ( type ) . merge parameters if resource_present? type , title debug "#{type.capitalize}[#{title}] was found in the catalog, updating it!" update_resource type , title , parameters else if type_create? type or title_create? title debug "#{type.capitalize}[#{title}] was not found in the catalog, creating it!" new_resources << create_resource ( type , title , parameters ) else debug "#{type.capitalize}[#{title}] was not found in the catalog, skipping it!" next end end end end new_resources end
The main method of this metatype.
The main method of this metatype .
None
Array<Puppet::Type>